Thursday, July 30, 2009

Please help with this computer program in c?

it tells me i have unresolved externals


#include%26lt;stdio.h%26gt;


#include%26lt;ctype.h%26gt;


#include%26lt;string.h%26gt;


#include%26lt;stdlib.h%26gt;


#include%26lt;math.h%26gt;





char * vowel_rule(char *);


char * two_letter(char *);


char * last_rule(char *);


void rules();





int main()


{





rules();





return(0);


}





void rules()


{


char str[80];


char english[80];


int length,a,b,i;





i=0;


a=b=0;





printf("Please enter a phrase to be translated to piglatin: ");


fgets(str,79,stdin);


length = strlen(str);





printf("\nThis is your translated sentence: ");





while(a%26lt;=length)


{


english[b]=str[a];


if(english[b]==' '||english[b]=='\0')


{


english[b]='\0';


b=0;





if(english[0]=='A'||english[0]=='E'||e...


||english[0]=='i'||english[0]=='o'||en...


{


printf(" %s",vowel_rule(english));


}





char * vowel_rule(char *str)


}


static char temp[80];


strncopy(temp,'\0',80);


strcpy(temp,str);


temp[strlen(temp)+1]= '\0';

Please help with this computer program in c?
The reference to strncopy should be to strncpy. I'm surprised the linker didn't give you a bit more information than it did, though.





But the strncpy doesn't do anything anyway. The strcpy from str into temp immediately overwrites the single \0 it would put down





Hope that helps.
Reply:Could be anything. Your going to have to see someone about that, check out CompUsa
Reply:What is that at the end after the line "char * vowel_rule(char *str)"?





Theres a closing brace but no opening brace, and even if that were right, it doesn't return anything. Did it get gorped up when you copied it here?





Not to mention that I count 4 opening braces in rules(), and only 1 closing brace.





Update: I'm not familiar with your build environment, but I don't think your program compiled. Can you see the output from your C compiler? Try putting something in the code you know is an error, like "Hi, Mom!", and see if it does the same thing.





Update again: Sorry, but this program is a train wreck. I think you should start by writing a "Hello World" program, and getting that to compile and run. Then start expanding it a little at a time to get it to do what you want.
Reply:while(a%26lt;=length)





Your %26lt; will fry you.
Reply:It would be useful if you provided more information:





1) The commands you are running to compile and link the program (unless you are using an IDE)


2) The exact error message - does it list the symbols?
Reply:Its weird.


You have declared main() correctly.


Maybe it requires


int main(int argc, char **argv)


instead


No comments:

Post a Comment