Talula
Develop front-end software.
I wouldn't recommend doing Win32 development in C++ unless you're using Qt as a tool and if you don't know about Windows programming, Qt wouldn't be the right place to start...
Try something like C#
Nobody🪲
#include<stdio.h>
#include<math.h>
int main()
{
float angle,sin,cos,tan;
printf("enter an angle:/n");
scanf("%f",angle);
//degree to radian//
angle=angle*3.14/180;
sin=sin(angle);
cos=cos(angle);
tan=tan(angle);
printf("sin=%f cos=%f tan=%f\n",sin,cos,tan);
return 0;
}
Nobody🪲
whats wrong with this
klimi
Nobody🪲
H
Why does c have so many vulnerable functions in the standard library? Like today I learned that basic functions like printf and scanf are vulnerable to format string exploits and buffer overflows.
Why aren't these functions rewritten so they can be secure?
H
Ok
\Device\NUL
\Device\NUL
You can use max field width on both printf and scanf to limit buffer. Check what scanf return
\Device\NUL
But i prefer input string than convert it rather than check what scanf return
Anonymous
the scanf_s privated goods added by Microsoft
n
why is it unsafe? please explain
Anonymous
lol
Anonymous
#pragma warning(disable : 4996)
artemetra 🇺🇦
what's the point of using x & 0xFFFFFFFF in code? doesn't it just leave the bits as is? or am i missing something
Anonymous
I think it should be understood in combination with the actual code
...
artemetra 🇺🇦
Anonymous
I remember this operation can be derived to find out how many 1s there are in the binary of a number
Anonymous
using the & and |
n
ok guys i am more confused right now😂😅
...
does it trim them?
well, you're esentially cutting out every bit that is set in FFFFFFFF
...
Anonymous
In fact, many things are very bad to realize by themselves
Anonymous
But I think it's also a good way to exercise ur thinking, not to build wheels repeatedly. lol
...
In fact, many things are very bad to realize by themselves
in this case especially, you're making it much harder for the compiler to optimize your code. there are cpu architectures that implement popcount as a instruction, lookup "nsa instruction" if you want to read up on some funny trivia :D
artemetra 🇺🇦
Anonymous
okk
artemetra 🇺🇦
artemetra 🇺🇦
okay, i think i got it, thank you guys
Anonymous
bit operation is still used in the embedded direction, such as stm32
Anonymous
😢I don't want to deal with bit operators at all
Anonymous
lol
Anonymous
my major will be studied in the future, but I prefer software engineering
\Device\NUL
%Nikita
That's the thing, I don't need to "think" how the compiler initializes the memory. I can just ask, and I will know for a fact. In order to compile the code, I supposed the type was a char[16].
In this case, GCC will do exactly the same thing for any of the following pieces of code:
1) char x[16] = {0};
2) char x[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
3) char x[16]; memset(x, 0, sizeof(char[16]));
And this is how GCC tells me it will do:
xorl %eax, %eax
The funny thing is why does it write that assembly instead of this:
mov eax,0x0
Apparently, the xor code is faster than the mov one, and that's what GCC will do when you use the -O3 switch.
Also in gcc you can fill array like
4) char x[16] = { [0 … 15] = 0 };
\Device\NUL
Except for the memset , I agree that could be an alternate
Ольга
Hi there. I hope someone will tell. How to find the smallest number of an array from the end? I wrote the code but the location of the item is not determined correctly
\Device\NUL
\Device\NUL
Also, Consider change your array. Variable length array is slow and dangerous. It could lead to Stack Overflow
Ольга
Ольга
It is my task
Ольга
It is short what I want
smallest=arr[0][0];
for(i=m-1; i>0;i--)
{
for(j=n-1;j>0;j--){
if(smallest>arr[i][j])
{
smallest=arr[i][j];
smallrowloc=i;
smallcolumnloc=j;
}
}
}
printf("Smallest element in array is %d in location arr[%d][%d]\n",
smallest, smallrowloc, smallcolumnloc);
return 0;
}
\Device\NUL
\Device\NUL
Maybe your program doesn't goes intro branch,
main.c: In function ‘main’:
main.c:75:3: warning: ‘smallcolumnloc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
75 | printf("Smallest element in array is %d in location arr[%d][%d]\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 | smallest, smallrowloc, smallcolumnloc);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:75:3: warning: ‘smallrowloc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
main.c:73:3: warning: ‘largcolumnloc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
73 | printf("Largest element in array is %d in location arr[%d][%d]\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | largest, largrowloc, largcolumnloc);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:73:3: warning: ‘largrowloc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
Ольга
\Device\NUL
babi
Explain array of structure with example
\Device\NUL
babi
Ok were is example
babi
Don't understand
Ольга
\Device\NUL
Ольга
Vitalii
Hey, I have a question, whether it is necessary to allocate "size + 1" here at allocation of dynamic storage for a zero-character or simply "size" is enough?
...
int size = strlen(someStr);
char* s = new char[size]; or char char* s = new char[size + 1];
strcpy(s, someStr);
'cause it works in both cases...
Ольга
Hi there. Maybe someone will help. I don't understand why my sum is not declared if I wrote a function for it. I hope for help
https://onlinegdb.com/lxmHbiY1Pp
Captain
Vitalii
Ольга
Someone can help now?
klimi
you wrote suma not sum
Ольга
you wrote suma not sum
If you me?Thanks, but I have already solved that problem. Now I am faced with the fact that the code does not do what is needed. This code don't make sorting. But I think it everything was correct
Anonymous
how to write simple quadratic c program???
Danya🔥
Anonymous
hi your welcome
Anonymous
Andrey
remove line 7