Thread: Strange printf

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    230

    Strange printf

    First of all i fixed my mistake by intializinf i, j to zero. BUT, if i do not initialize them to zero the printf function prints '0' and '92'(which according to ascii code is 'a'). Why this? Basically why it prints j as char? thanks in advance...
    Code:
    void kratisi(char **Names, int Nseats){ // calling this function with: (Names, Nseats)
    	int i=0, j=0, posValue;
    	char curName[30];
    		printf("arxi synartisis ---- i: %d, j: %d\n", i, );
    ...
    }

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Take a close look at your printf statement... what's missing?

  3. #3
    printf("Hello Cboard\n"); codeprada's Avatar
    Join Date
    Jan 2011
    Location
    In a little room at the back of your brain
    Posts
    68
    the extra %d causes printf to print rubbish
    We shouldn't be quick to criticize unless we can do better.
    Code:
    public function __clone() { die ( "I'm one of a kind" ); }

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by codeprada View Post
    the extra %d causes printf to print rubbish
    Take a closer look at his code... it's not an extraneious %d... Look at the format string... he's missing a variable.

  5. #5
    Registered User
    Join Date
    Aug 2010
    Posts
    230
    yes right! thanks...its another mistake for not sleeping well! lol

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please help!
    By Cdre in forum C Programming
    Replies: 3
    Last Post: 02-12-2011, 10:14 AM
  2. C Code Please Help
    By Cdre in forum C Programming
    Replies: 3
    Last Post: 02-02-2011, 01:32 AM
  3. Replies: 3
    Last Post: 01-29-2011, 04:54 AM
  4. Trouble with two two dimensional arrays
    By scmurphy64 in forum C Programming
    Replies: 5
    Last Post: 12-06-2009, 06:57 PM
  5. Replies: 4
    Last Post: 04-01-2003, 12:49 AM