Search:

Type: Posts; User: w2look

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    10,603

    Yeah, I have since figured that out. However,...

    Yeah, I have since figured that out.

    However, for my own purposes, I wanted to get rid of the \n being stored at the
    end of the string so I'm using it like:


    ...
  2. Replies
    6
    Views
    10,603

    Thanks for the suggestion! I tried: ...

    Thanks for the suggestion!

    I tried:



    fgets(ptrNew->fname,40,stdin) ;
    ptrNew->fname[strlen(ptrNew->fname)]='\0';
  3. Replies
    6
    Views
    10,603

    Thanks, that was actually my next question. I'll...

    Thanks, that was actually my next question.
    I'll give gets a whirl and see if I can make it work.
  4. Replies
    6
    Views
    10,603

    Fill a linked list char by char

    Hi, I am writing a contact book program using linked lists and I want to fill the
    elements of the lists character by character. The reason I want to do it char by char
    is to allow spaces when I...
  5. Replies
    6
    Views
    3,922

    Sometimes you just have to walk away from the...

    Sometimes you just have to walk away from the computer and clear your head.

    The solution came to me as I was cooking breakfast this morning.

    You have to pass it two pointers. One to the start...
  6. Replies
    6
    Views
    3,922

    A little more Info

    This is what the constraints of the project are:

    Write a function called Reverse that accepts as a parameter a char array (or char pointer)
    and returns a void. The function reverses the contents...
  7. Replies
    6
    Views
    3,922

    Another String Problem

    I am not looking for a coded solution!

    Please just point me in the direction of how to fix what I am doing wrong if you can.

    I am working on a project for class to reverse a string. I have...
  8. Replies
    20
    Views
    12,674

    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...
  9. Replies
    20
    Views
    12,674

    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, " .,;");
  10. Replies
    20
    Views
    12,674

    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...
  11. Replies
    20
    Views
    12,674

    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);
  12. Replies
    20
    Views
    12,674

    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?
  13. Replies
    20
    Views
    12,674

    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...
  14. Replies
    20
    Views
    12,674

    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...
  15. Replies
    20
    Views
    12,674

    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...
  16. Replies
    20
    Views
    12,674

    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);
  17. Replies
    20
    Views
    12,674

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

    Do I use an if statement for that?

    like

    if (character == NULL)
    break;
  18. Replies
    20
    Views
    12,674

    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.
  19. Replies
    20
    Views
    12,674

    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);
  20. Replies
    20
    Views
    12,674

    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...
  21. Replies
    8
    Views
    23,293

    Wow! Thanks for all the replies. I actually...

    Wow!

    Thanks for all the replies.

    I actually got it to work while I was away from the board.
    However, I did it by cheating.
    The function I wrote will return the array with all the elements...
  22. Replies
    8
    Views
    23,293

    OK, here is what I have come up with. void...

    OK, here is what I have come up with.



    void LeftShift2D(int array [R] [C])
    {
    int lim = R * C;
    int temp = array[R-1] [C-1];

    for(int i = lim - 1; i >= 0; i--)
  23. Replies
    8
    Views
    23,293

    So I guess I should use 2 temporary variables...

    So I guess I should use 2 temporary variables then.
    One for the first element that I will keep until the end
    And one to temporarily keep the elements that I'm moving.

    How do I keep from...
  24. Replies
    8
    Views
    23,293

    Left Shift elements of a 2D array

    I am rather new to C programming and I am trying to learn as much as possible.
    We recently had an assignment centered around 2D arrays.
    We had to write several functions...
    ...
  25. Replies
    14
    Views
    33,488

    Thank you everyone!

    You have all been a great help and I think that I may have
    taken a little something from each of you in the way of
    advice to finally finish the problem.

    This is what I have come up with and...
Results 1 to 25 of 31
Page 1 of 2 1 2