Read data from txt file (nucleo F401RE)

am I missing something here?

I have the following code and would like to read the data in the file and print in the serial monitor but it is constantly just printing cant read file

I know I’ve got the file path correct as I’ve tested the code in VS

the code runs just fine but it can never “see” the file

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

int main()
    char str[80];
    FILE* filepointer = fopen("C:/Users/user/Desktop/textfile.txt", "r");
    if (filepointer == NULL) {
        printf("Can't open file\n");
    else {
        while (!feof(filepointer)) {
            fscanf(filepointer, "%s", str);
            printf("%s ", str);


I think it is not possible to read any file directly from PC, you have no access to PC’s file system.

BR, Jan

ah okay thanks for that, I guess I will invest in an SD card break-out board

thanks for your help!