Search:

Type: Posts; User: w2look

Search: Search took 0.00 seconds.

  1. Replies
    20
    Views
    12,678

    Why not? The next part of the problem involved...

    Why not?

    The next part of the problem involved taking the newly "parsed" array of words, sorting them in alphabetical order and then printing them.



    //prototypes
    void ParseSentence(char...
  2. Replies
    20
    Views
    12,678

    Actually, I think I got it! Changed the code...

    Actually, I think I got it!

    Changed the code in the for loop to:



    for(i = 1; i < size - 1; i++)
    {

    words[i] = strtok(NULL, " .,;");
  3. Replies
    20
    Views
    12,678

    I see what you're saying, I have since moved on...

    I see what you're saying, I have since moved on to the next part of this problem and it is causing me problems. While I am getting the printed output I desired, the words are not being stored in the...
  4. Replies
    20
    Views
    12,678

    OK, this time I think I've got it. void...

    OK, this time I think I've got it.



    void ParseSentence(char *ptrA)
    {
    char temp[80];
    int i;

    strcpy(temp, ptrA);
  5. Replies
    20
    Views
    12,678

    looks like I spoke too soon. no more seg...

    looks like I spoke too soon.

    no more seg fault, but not printing past the first word

    hmm?
  6. Replies
    20
    Views
    12,678

    I don't know what I was thinking, I didn't need a...

    I don't know what I was thinking, I didn't need a while loop at all.
    If I was smarter and read your advice thoroughly, I would have saved myself some time.

    i.e. "You need to print until you run...
  7. Replies
    20
    Views
    12,678

    I'm not quite sure where you got the # 40 from....

    I'm not quite sure where you got the # 40 from. The default size of the buffer for user input is 80 chars. But what you suggest makes sense. I guess I should be using a while loop instead of a for...
  8. Replies
    20
    Views
    12,678

    I thought that there may be a possibility of...

    I thought that there may be a possibility of another part of my program causing the problem
    so I put everything regarding this function into it's own program to try and isolate the problem.
    Here is...
  9. Replies
    20
    Views
    12,678

    Tried changing it to this, but same result. ...

    Tried changing it to this, but same result.



    void ParseSentence(char *ptrA)
    {
    char temp[80];
    char *words[80];
    strcpy(temp, ptrA);
  10. Replies
    20
    Views
    12,678

    Do I use an if statement for that? like if...

    Do I use an if statement for that?

    like

    if (character == NULL)
    break;
  11. Replies
    20
    Views
    12,678

    Should I be copying the char array being passed...

    Should I be copying the char array being passed to the function into a temp array before using strtok?

    If so, how do I do that? I'm kinda new to C.
  12. Replies
    20
    Views
    12,678

    OK, I changed the code to the following. Still...

    OK, I changed the code to the following.
    Still getting the same result.



    //prototype *was wrong in initial post*
    void ParseSentence(char *ptrA);

    //call in main
    ParseSentence(Buffer3);
  13. Replies
    20
    Views
    12,678

    Help with parsing a sentence.

    I am writing a function to parse a sentence and print each separate word on a new line.
    For some reason, I keep getting a Seg fault. Can anyone please tell me what I am doing wrong?
    It is...
Results 1 to 13 of 13