Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Strings and arr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 25178 of 28006
Post > Topic >>

Strings and arrays

by Jim <jim.moneytime@[EMAIL PROTECTED] > Mar 28, 2008 at 10:02 AM

Hi There.

I have to create a function that will take a sentence and breakout the
words and save them into an array.  For some reason, I can't get it
working.  I keep getting a segmentation fault being caused by
strcpy().  Can someone please tell me what I'm doing wrong:

     88     void displayPigLatin(char *str) {
     89     void encode(char *sPtr);
     90
     91     char
     92         *arrStr[MAXWORDS][WORDSIZE],
     93         *tokenPtr,
     94         *tmpStr;
     95
     96     int cnt;
     97
     98     strcpy(arrStr[0][0], str);
     99     tokenPtr = strtok(arrStr[0][0], " ");
    100     printf("%s\n", tokenPtr);
 




 9 Posts in Topic:
Strings and arrays
Jim <jim.moneytime@[EM  2008-03-28 10:02:25 
Re: Strings and arrays
Jim <jim.moneytime@[EM  2008-03-28 10:06:14 
Re: Strings and arrays
fred.l.kleinschmidt@[EMAI  2008-03-28 10:09:57 
Re: Strings and arrays
Jim <jim.moneytime@[EM  2008-03-28 10:13:29 
Re: Strings and arrays
Ben Bacarisse <ben.use  2008-03-28 17:50:17 
Re: Strings and arrays
Jim <jim.moneytime@[EM  2008-03-28 12:50:49 
Re: Strings and arrays
CBFalconer <cbfalconer  2008-03-28 16:10:58 
Re: Strings and arrays
Ben Bacarisse <ben.use  2008-03-28 22:59:45 
Re: Strings and arrays
Thad Smith <ThadSmith@  2008-03-28 20:42:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 12:01:20 CST 2008.