I'm very new to programming and C. I have textfile with some random text and an integer that i want to find and save. The textfile looks something like this (I only want to save 23 in this case, not 56):
# this is a comment
23
this is some random text
56
And this is the code I have:
    int *num = malloc(sizeof(int));
    *num = fgetc(f);
    while(!feof(f)){
        *num = fgetc(f);
        if(isdigit(*num)){
            break;
        }
    }
    if(!isdigit(*num)){
        printf("Error: no number found.\n");
        free(num);
    }
    else{
        printf("%c\n", *num);
    }
I'm kinda stuck right now and my program only prints out the number 2 :/ Very thankful for help.
 
     
     
    