I canít get my head around this problem. In the following code I want to enter a string that is a filename, for example hello.txt, myprog.bin assuming that they both exist on my c drive. However I want the program to accept .bin, .txt files only. If you donít enter the 2 extensions I mentioned an error is displayed. Im unsure on how to do the decision making part with the file extensions. I think there should be a for loop to loop around string or strcpy command used within the program to compare extensions but not to sure. Iíve attached a piece of code that relates to it. Any help would be grateful.
printf("Enter filename : "); //enter filename - example hello.txt would be valid
gets(string); //get file name
if (string != //unfinished here, unsure how to test condition
printf("Limit your entries to .bin, .txt extensions only"); //error message
printf("You entered %s with the correct extension\n", string); //otherwise prints correct text to screen