So a simple clean up of your program would perhaps look like this.
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE*fp;
char prompt;
char filename[15];
char text[100];
char assembly[10][50]= {
{"name ex3"},
{"org $500"},
{"ldaa $600"},
{"adda $601"},
{"staa $602"},
{"swi"},
{"org $600"},
{"fcb $20"},
{"fcb $30"},
{"end"}
};
printf( "Please enter the name of the file you wish to open: \n" );
fgets(filename, sizeof(filename), stdin);
filename[strlen(filename)-1]='\0';
fp = fopen(filename, "r");
if (fp == NULL)
{
printf( "ERROR the file you have chosen cannot be opened \n" );
printf( "Please make sure the file exists \n");
}
//comparison loop
while (fgets(text,100,fp) != NULL) {
printf("%s\n", text);
}
scanf("%c",&prompt);
fclose(fp);
return 0;
}
Aside from changing the file pointer's name, almost the only change is adding the assembly lines you posted - so it can be used to test the contents of the file. (also added: fclose(fp), return 0, and a pair of curly braces. Inside the format specifier for scanf("RIGHT HERE", &variableName), you should have no \n's. \n (newlines), go AT THE END of all printf() statements, (so the buffer gets flushed to the console or outprint stream).
I'm assuming that the assembly lines you posted were correct, and copied that into the TestAssembly.txt file - but I copied it twice, and changed several lines so they are no longer correct.
The above doesn't DO anything just yet, but it does give a compilable program, with the framework code you posted.
The logic will be in that "comparison loop".
See if that makes sense to you, and read up on strcmp() - part of string.h.
Would a for loop from 0 to 9, using strcmp(string1, assembly[i]) be useful in this instance? Of course, the return from strstr() is an int, so you'd need to add that to your program - and one more int for the for() loop counter. (by tradition, called i).