my code to read file, but how can i split strings and then convert them?
Code:
#include <stdio.h>
#include <string.h>
int main( int argc, char *argv[] )
{
char buffer[10000]; // longest line
int i, nr;
if ( argc != 2)
{
printf("usage: %s filename", argv[0]);
}
else
{
FILE *input = fopen( argv[1], "r");
if ( input == NULL);
{
printf("Error opening file \n");
exit(-1);
}
nr = 0; // line_nr before while 0
while(fgets(buffer, sizeof(buffer), input) != NULL)
{
nr++; // increase number
printf("%d.%s", nr, buffer); // puting line_nr before line
}
fclose (input); // closing input_file
return 0;
}
}
Abies