Thread: not running properly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    It's great fun to try different things with C, but when you are serious about working on a program, it's time to limit the guessing on this, guessing on that, approach.

    Take it step by step (don't jump ahead of what you're doing atm), and don't go crazy with guesses and emotions. Let's see what's up now.

    Let's change this part, from == NULL, to != NULL, and add the curly braces to it as well. The curly braces aren't required, but your other if statements have them, and it's VERY good to be consistent and clear in your code and coding style.

    Code:
        if(fgets(command,  MAX_CMD_LEN, stdin) != NULL) { //add curly braces
           if((p = strchr( command, '\n')) != NULL)             //change from == NULL to != NULL
             *p = '\0';
        } //add curly brace.
    Give that a try.
    Last edited by Adak; 10-23-2012 at 08:47 PM.

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    210
    You tell me I'm out of ideas of what could be wrong

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    210
    Nevermind got it had to change my function append

    THANK YOU!!!

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    210
    OMGSH your a lifesaver!
    i don't know why i didn't think of that before
    do you know why my list doesn't print out my "appended function"
    it prints out the new just fine

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by kiwi101 View Post
    OMGSH your a lifesaver!
    i don't know why i didn't think of that before
    do you know why my list doesn't print out my "appended function"
    it prints out the new just fine
    Actually, I HAVE BEEN a lifesaver, but not any more for sure.

    You're welcome, Kiwi.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 12-09-2008, 11:09 AM
  2. For loop not running properly
    By Todd88 in forum C++ Programming
    Replies: 21
    Last Post: 04-04-2008, 05:27 PM
  3. How to properly use flock()
    By samps005 in forum Linux Programming
    Replies: 5
    Last Post: 05-06-2003, 12:22 AM
  4. plz hlp me. program not running properly
    By jfl in forum C Programming
    Replies: 5
    Last Post: 02-11-2002, 03:58 PM
  5. Am I using *this properly?
    By Sebastiani in forum C++ Programming
    Replies: 3
    Last Post: 12-20-2001, 06:06 PM