Hey guys, so I have a bit of a silly problem. I'm starting to write a program in MS visual studio that requires me to open a user specified file. I've created the file in notepad, but when I run the code, it always tells me that the file doesn't exist and that's not true. Here is my code:
Also, for some reason my #include stackADT.h is not recognized... but that's a piece of code that my teacher specified. Why does the compiler not like it?Code:#include <stdio.h> #include <stdlib.h> #ifdef _MSC_VER #include <crtdbg.h> // needed to check for memory leaks (Windows only!) #endif #include "stackADT.h" int main (void) { // Local Definitions FILE *fp; char filename[100] = ""; // Statements printf("\n\n\t\tHomework 1: STACK ADT\n\n"); printf("\tThis program ...\n" ); printf("Please enter the name of the file that you want to use: \n"); scanf("%s", &filename); fp = fopen(filename, "r"); if(fp == NULL) { printf("Your filename was not found!\n"); exit(100); } printf("\n\t\tThank you for using the program," "\n\t\tHave a great day!\n"); #ifdef _MSC_VER printf( _CrtDumpMemoryLeaks() ? "Memory Leak\n" : "No Memory Leak\n"); #endif return 0; } // main
Thank you for your time.



LinkBack URL
About LinkBacks



[/edit]