Well I assume this answer is out there but man is there a flood of people posting the code. I cannot find where it is actually implemented. I am using codeblocks and I am passing the filename into main. But when I click Run, there is no filename that was passed in. How do I pass in a filename in Codeblocks? Do I use cmd promt or what? I want to pass in input.txt but I can't figure it out. Right now to stop it from crashing, I just have it default to input.txt.
nfile = fopen(argv[1], "r+");
// Check for file open
if (nfile == NULL) {
nfile = fopen("input.txt", "r+");
printf("FILE NAME: %s argv\n", argv);
if (nfile == NULL) {
printf("Failed to open file. Must have file name (input.txt)\n");
return -1;
}
}