Anmol
Ohh right, i forgot that scanf returned number of characters
Francisco
help guys!!!!!!!!!!!!
Translation: I have some assingment to do, and don't feel like doing it, so please do it for me
Anonymous
hey guys ! please I have tried to return the length of an pointer of array in c an I don't know how to do it please help here is an extraction of the program int* t ={35,68,78,89}; int l; l = sizeof(t)/ sizeof (t[0]); / it is not working please help
Artöm
t is a pointer
Anonymous
You can do this sizeof trick only on static arrays
ah ok!! is there no other way to get the length of this array??
Artöm
No, you have to save it beforehand
Anonymous
No, you have to save it beforehand
ah ok ! please help me with the code to save it beforehand
Artöm
size_t size = 4; int* t = new int[size]{1, 2, 3, 4};
Noor
How to check if float is somthing.000000 or close?
Noor
Ive tried fabsf(roundf(x) - x) <= 0.001f but its not working on bigger number
Noor
I need help guys
Patrick
and so, can't you write fabsf(x) < 1 && ...?
Patrick
It supposes to handle till 12.00000.
ahhh, you want to check if it's close to x.0, my apologies
Patrick
Can you use an integer instead?
Patrick
If you need it as a float you can divide it by the precision you want, such as 1000
Patrick
Sure. So, make StepFactor an int, and do ++StepFactor; instead of StepFactor += 0.01; Then your if statement becomes if (StepFactor < NodeSize * 100)
Patrick
and if you need StepFactor as a float, (float)StepFactor / 100
Noor
Sure. So, make StepFactor an int, and do ++StepFactor; instead of StepFactor += 0.01; Then your if statement becomes if (StepFactor < NodeSize * 100)
No, the reason its float is because its an animation project i need the float so the movement is not juggy.
Noor
and this won't work for you?
It breaks the animations.
Patrick
How?
Patrick
float StepFactor = 0; StepFactor += 0.01; //Now 0.01 StepFactor += 0.01; //Now 0.02 int StepFactor = 0; ++StepFactor; //Now 1, and StepFactor / 100 = 0.01 ++StepFactor; //Now 2, and StepFactor / 100 = 0.02
Patrick
I mean
Patrick
why wouldn't (float)StepFactor / 100 work?
Patrick
I don't think you have understood my suggestion, mate
Noor
Thank you, It works!
Patrick
Still
Patrick
What you're using: //Declaration float StepFactor = 0; //Incrementation StepFactor += 0.01; //Usage doSomething(StepFactor); //Checking if it's near a whole number if (((1-0.0001f) < (roundf(StepFactor)/StepFactor)) && ((roundf(StepFactor)/StepFactor) < (1+0.00001f))) My proposal: //Declaration int StepFactor = 0; //Incrementation ++StepFactor; //Usage doSomething((float)StepFactor / 100); //Checking if it's near a whole number if (!(StepFactor % 100))
Daniel
Daniel
Why this “gets” in the command black window hasn’t blink cursor ,it doesn’t run the gets function,and the bottom function it seems two lines on the command black window but i type just one line code
Daniel
🤦🏼‍♂️ need help
Daniel
Why do I need calling that gets😶
Daniel
I see, thanks bro
Daniel
But why that fgets print out two lines on the screen
Moe The God's
Can you tell me the category of Data type
Anonymous
Thanks for joining me
Anonymous
stahp using gets()
Anonymous
But why that fgets print out two lines on the screen
gets() discards any newline character found at end of line puts() adds a newline character when printing a string fgets() keeps the newline character in the string if it fits fputs() prints the string as is
Anonymous
inventing an inline function that does fgets() followed by if ((newline = strchr(string, '\n')) != NULL) { newline = '\0'; } else { discard upto newline using getchar() } is often a good idea if you need consistency between puts() and fputs()
Daniel
You means whenever gets reads \n ,is going to discard the gets function ?
Daniel
🧐those code really complicated
Anonymous
You means whenever gets reads \n ,is going to discard the gets function ?
no. gets() will read entire line regardless of whether it is 100 characters or 10 [note 1] until it finds a '\n' (or EOF). when it finds one, it will read the '\n' from the stream, but won't store it in the string [note 1] causing security issues, which is why gets() has been removed from the C standard. stop using it
Daniel
I’m Kind of confused 😂,
Anonymous
I’m Kind of confused 😂,
step 1) stop using gets() because it doesn't do bounds checking
Daniel
😂😂😂😂
Daniel
Oo I see
Daniel
I just thought it no need to type ampersand something
Anonymous
I just thought it no need to type ampersand something
arrays decay into pointers, the ampersand is inbuilt
Anonymous
int arr[4]; <- type of arr is int[4]; function(arr); <- type of arr is int *
Daniel
😂yeh
Anonymous
arrays decay into pointers, the ampersand is inbuilt
the only exception to this is the sizeof operator (in C)
Daniel
I see , sizeof kind of turn array into variable
Daniel
😂is it having step2
Anonymous
😂is it having step2
step 2) use fgets() with newline remover (search on stack overflow and copy 🤷‍♂️)
Anonymous
oh right @& operator didn't know about string literals actually having a named type lol
Dima
lol
Anonymous
sambit
What data structure are really required in programming language
Mar!o
Integers and Floats
Mar!o
And pointers are required too but they can be hidden
IBRAHIM
Hi
IBRAHIM
Plz can someone tell me how image are been represented in a computer
Dima
lol
Rania
Plz can someone tell me how image are been represented in a computer
First of all, you can find it in THE VERY FIRST page on Google result. Second, your question is unrelated to C/C++.
Hermann
is possible use pointer of struct1 to reference struct2?