This is my code. As you can see it doesn't do much.
#include <iostream>
#include <string>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
using namespace std;
int main(int argc, char * argv[]){
//check for correct number of files
if(argc < 2){
cout << "You must specify a file name" << endl;
return 1;
}
if(argc > 11){
cout << "Error: Too many file names specified." << endl;
return 1;
}
//define structure and other variables
struct stat {
mode_t st_mode;
ino_t st_ino;
dev_t st_dev;
nlink_t st_link;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
blksize_t st_blksize;
blkcnt_t st_blocks;
};
return 0;
}
I get the following error when I try to compile:
lab2.cpp: In function int main(int, char**):
lab2.cpp:30: error: expected ; before . token
lab2.cpp:31: error: expected ; before . token
lab2.cpp:32: error: expected ; before . token
The structure is taken straight from my book. My guess is that I'm missing an include file somewhere. If I comment out the time_t lines, the code compiles. The program seems free of syntax errors so I'm not sure what the problem is. Any help is appreciated.