void openFile ( char *filename );
...
openFile ( argv[1] );
Type: Posts; User: codepoet
void openFile ( char *filename );
...
openFile ( argv[1] );
i don't care if the standard says he should stand on one foot and hop around the room while coding main. he didn't ask "how can i make my code more C99 compliant?", he asked about reading data files...
seriously man, get over it.
ignoring the question he asked and criticizing something as trivial as his coding style doesn't accomplish anything except make you look condescending, arrogant, and...
- use two loops, one with fgets() to loop through the sentences, and one with strtok() to split each sentence into words
- total_words variable that increments by 1 inside the 2nd loop as you find...
you can write your own printf wrapper function, using a va list and vsnprintf, then just do something like ( console size - length of string ) / 2 to find out how much whitespace to output before...
in that case, here is a solution better suited for higher values of ARRAY_SIZE, as well as being more efficient by limiting the number of calls to rand() to just ARRAY_SIZE...
#include...
you're right, i did miss it! sorry...
and i didn't see that anywhere, i was trying to bring you two back on topic. you seem to have veered off on a related tangent, but it wasn't applicable to...
no, i'm not missing the point; i'm afraid both of you are. you can't input 0 into x and have it come out 0.0000001. the inaccuracy of floating point numbers doesn't apply to zero, and the computer...
maybe something like this...
#include <stdlib.h>
#include <time.h>
#define ARRAY_SIZE 9
int array[ARRAY_SIZE] = {0};
i don't see why some people don't like it... it's very easy to use, and works great (as long as you validate your string before calling it).
1) read in one line using fgets()
2) loop through the line by using strtok() to split it up, delimited by spaces
3) while in the loop, process each word
4) rinse and repeat until all your lines...
yes, i know. however, zero of any magnitude is still zero, and unary negation should still fit the bill in this case (!0, !0.0, !0.0000, etc should all still return 1).
the original poster wanted to compare variables to absolute zero, not zero within a tolerance (at least that's how i interpreted his code), so i don't understand why you guys are providing solutions...
it's not annoying; forums like this exist with the primary goal of sharing knowledge via q&a format. besides, i can about guarantee that anyone with the ability to answer your question probably had...