RSS Forums RSS
Please support our C advertiser: Programming Forums

Can someone help me with my programming?

Join Date: Oct 2007
Posts: 5
Reputation: skyah is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
skyah skyah is offline Offline
Newbie Poster

Question Can someone help me with my programming?

  #1  
Oct 16th, 2007
I have to write an interactive program using scanf() to read in seven strings input by the user. The program should print the seven strings as a list, then sort them alphabetically and print a new list. I have to use the function strcmp() to assist in the sorting of the strings and also use the preprocessing directive #define N_STRINGS 7. The program must sort a different number of strings by changing only that line. This is what I have so far.
#include stdio.h
#include string.h
#define N_STRINGS 7
#define arrayword 15
#define maxletters 15

int main(void)
{
int i, j, c;
char line[N_STRINGS][arrayword];
char temp[maxletters];

printf("\nPlease type in %d words : ",N_STRINGS);
for (i = 0; i < N_STRINGS; ++i)
scanf("%s", line[i]);

printf("\nHere is the list you entered:\n\n");
for (i = 0; i < N_STRINGS; ++i)
printf("%s\n", line[i]);

printf("\n\nalphabetically sorted for you:\n");
for (i = 0; i < N_STRINGS; ++i)
printf("%s\n", line[i]);

return 0;
}Error 1 error C2006: '#include' : expected a filename, found 'identifier' c:\documents and settings\skyah\my documents\visual studio 2005\projects\10 10\10 10\10 10.cpp 1
Error 2 fatal error C1083: Cannot open include file: '': No such file or directory c:\documents and settings\skyah\my documents\visual studio 2005\projects\10 10\10 10\10 10.cpp 1
PLEASE HELP ME IF YOU CAN.
Can someone please help me? These are the error messages i received:
AddThis Social Bookmark Button
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:34 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC