hello everyone ..
im writting a C program that requires to insert
integers from a text file ..
the contents of the text file are:

1:2:4
4:12:5
13:7:5
1:20:4

how can i read each number and define it as an integer ????
please HELP !!

#include <stdio.h>
int main()
{
FILE *input;
input  = fopen("input.txt", "r"); /* r for defining the mode r=read */

if (input==NULL)
{
printf("Cannot Open input.txt file !\n");
return 1;                                
}
else 
{
printf("The File is Open n\n");
int i;
/* in here what should i do to read the file */
}
return 0;
}

how can i read each number and define it as an integer ????

Try googling strtol, strtoll, strtoq - convert a string to a long integer

well you know that the file contains an integer and a char and it repeats.
So read in a integer first then read in the char. Use the integer and forget
about the char.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.