so i read files with fopen
i read a string with a certain lenght( wich is defined with strlen)
then i say if theres a character wich is digit (isdigit(c))
then he has to read the string until it finished presuming there are only digits after the first digit
now my problem is i want to store the numbers in a variable how should i do
heres some of the code...
thxCode:#include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <string.h> #define size 100 int main(){ FILE *data; char lijn[size]; char c; int lengte; int teller=0; int OFM; data=fopen("dat.txt","r"); if(data==0){ printf("Kon het bestand dat.txt niet openen"); exit(-1); } do{ fgets(lijn,size,data); lengte=strlen(lijn); for(int i=0;i<lengte;i++){ c=lijn[i]; printf("%c",c); if(i==lengte){printf("\n");} if(isdigit(c){ /*here has to be some code that reas until the string is finished and puts the number in a variable*/ } } while(!feof(data)); fclose(data); return 0; }