cp /home/newhall/public/cs21/week12/babies.c .
# to read in a line of up to 50 chars long from a file into a string # (str is an allocated string, and infile is a FILE* to file to read from): fgets(str, 50, infile); # fgets put the '\n' in the string it returns before adding '\0' # if it reads in a '\n', you should replace '\n' in the string with '\0' str[strlen(str)-1] = '\0'; # you can then use the function atoi to convert a string to an int num = atoi(str); # if str is "1234", this returns the int value 1234
You probably will want to make use of the functions atoi() and atof().