Quote:
Originally Posted by elenizi
i did change the points you recommended and found out the problem was a type conflict when using atoi from my input file... i had misunderstood the use of atoi... my general point of view it to get a line of text from an input file and then categorize it and do virtual calculations with what it says for example if it says add i have to add the initial contents of the two variables that follow add but i am having a problem finding a way to read that line save it in a table and then get it back and cut it into pieces to get the instruction and the variables... does anyone have any ideas how to do this? =/
|
atoi() attempts to convert a string commencing with numerical characters into an integer number; it is not very wise to use this function because it will return 0 (zero) if it is unable to deduce a number from the string. And 0, as you know, is a valid number.
When reading raw input, maybe even from a file, use fgets() to get the line of data and then use sscanf() to parse the data. sscanf() will return the number of successful fields it was able to parse. If you are expecting a single number, and sscanf() return 0, well, that's a clue it failed to parse that number.
Anyhow, we (perhaps only I) have no clue as to what your data looks like. Perhaps if you posted your code and a sample of your data file we could assist you more.