Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with C Programming assignment
#13
"char first, second;"

That declares a variable named "first" which is assigned one byte. You need it to be a pointer.

"char* first, second;"

This makes "first" be a memory location for an array of characters (whether string or actual array - in C these are the same concept) somewhere else in memory. The way it was before was a reference to one byte of memory.

Also, because it's a pointer, you don't need the "&" in the scanf function call because your char* is already a pointer.

scanf("%s", first);

Also, instead of using "system("PAUSE");", try running your programs from the command prompt.

Finally, most C Programming courses allow functions to be global in scope, so you can move the function prototype for matchscore into the global section of the program.

" printf("The matchcount is %d\n", matchscore(first, second);" << missing a parenthesis there on the right?
Reply


Messages In This Thread
Need help with C Programming assignment - by Fiel - 2009-11-23, 09:18 PM
Need help with C Programming assignment - by Fiel - 2009-11-23, 09:22 PM
Need help with C Programming assignment - by Fiel - 2009-11-25, 08:13 AM
Need help with C Programming assignment - by Fiel - 2009-11-25, 11:51 AM

Forum Jump:


Users browsing this thread: