My answer only addresses your issue with the file name.
The shell interprets this: ~/asimes2/hw2/Makefile
It's not a valid filename to pass to stat() with the ~
You should be able replace the leading ~
with something link /home/
or wherever the actual home directory is.
Try this:
char* fullPath = malloc((80+strlen(filePath))*sizeof(char));
strcpy(fullPath, "/home/ubuntu/asimes2/hw2");
strcat(fullPath, filePath);
printf("Full path = '%s'\n", fullPath);