And all this time i thought a double was a floating point number with 2 decimal places...anyways, thanks for the counting idea, that should work!
Type: Posts; User: jerryR
And all this time i thought a double was a floating point number with 2 decimal places...anyways, thanks for the counting idea, that should work!
It does return 1 for numbers with double precision, but it also returns 1 for numbers with less/more precision...ie 12.22, 12.345, 12 all return 1 and I'm trying to make sure the only input allowed...
Is there any other way to make sure the number I get from stdin is a double, since sscanf cannot do it?
I'm trying to read a double from stdin in the following manner:
double value;
fgets(line, sizeof(line), stdin); // eg 12.54
sscanf(line, "%.2f", &value);
also tried %e, %g, %le, etc...none...
Thanks bithub..I really had no idea, I'm no good with pointers :confused: (nor C in general) and I had no clue this is what was happening!
Thanks again!
I'm sorry, i shoulnt have posted the whole code to begin with as there were several other problems, but im trying to focus in on this one problem i cant get past, and i left out one line when...
Thank you for your help! Is there a reason why an object that's not initialized isnt automatically set to NULL in C? default values?? Anyways, after applying your changes I get this output:
...
OK, I hope adding "= NULL" to "stockItem *stock = NULL" will help, but still not sure where stockList->symbol is being updated after adding 2nd, 3rd...etc items.
Thanks for the reply! I check if stock is NULL because I assume that the during the first iteration it is NULL, and after iterating through the list, it'll eventually come to be NULL as...
OK, reposted with indent and this code can be complied. Just cant seem to see where stockList->symbol is being changed after its being read from the command line...!?!
Ok, I originally thought the problem was with the threads but now i suspect sscanf, though i have no clue as to why, maybe someone can shed some light on the highlighted lines and the output below:
...