Hi all,

I'm in the early stages of learning C, and I want to develop on OSX. I wrote a simple program that uses fopen() on a .txt file (in the local directory of the source.c file) and uses fscanf() to read the first line into an integer.

It works fine using codeblocks in a windows environment, but it doesn't work on any ide I've tried on OSX. It returns "Segmentation Fault: 11". What am I missing?

Code:
#include <stdio.h>

int main ()
{
    int num = 0;
    FILE *fpointer;
    fpointer = fopen("test.txt", "r");
    fscanf(fpointer, "%d", &num);
    printf("%d\n", num);
    
    return 0;
}