Hello, I'm getting a segmentation fault in my code, at the IF statement. Can anyone tell me why? The printf() statement right before outputs the correct data, so *buffer definitely isn't null. Thanks for your help.
int main(int argc, char *argv[])
{
FILE *inputFile, *rejects;
char hold[200], hold2[30], *buffer = &hold[0], *buffer2;
int x = 0, numStudents = 0;
struct Student students[100], currentStudent;
/* opens the file */
inputFile = fopen(argv[1], "rt");
printf("\nFile %s opened...\n", argv[1]);
/* while there are still lines of input, read the next line */
while(fgets(hold, 150, inputFile))
{
printf("In the while loop...\n");
printf("input: %s", hold);
printf("*buffer: %c\nx: %d\n", *buffer, x);
/* seg. fault at this "if" statement */
if(*buffer == '|')
printf("no");
else
printf("Success");
.....