I am unable to read the data from the file created. This is a very simple code and I simply cannot understand why it is not working. I have just shifted to mac and installed the developer command line tools.
My code is :
int main()
{
    FILE *fp;
    int lines = 0;
    char *data;
    data = (char *)malloc(1000);
    data = NULL;
    fp = fopen("1.txt", "r");
    while (fgets(data, 1000, fp) != NULL)
    {
        printf("%s\n", data);
        lines++;
    }
    printf("Lines = %d\n", lines);
    free(data);
    fclose(fp);
    return 0;
}
 
    