Thread: Define statements conflicting with printf...

  1. #1
    Registered User
    Join Date
    May 2003

    Define statements conflicting with printf...

    Problem goes out like this.

    I want to replace the %d with, say, letter Q.

    Problem is, when I use the Q instead of %d inside printf statements, the printf prints out the Q, instead of the variables listed on the right.

    I wanted to know, if there is a way to get around this, or if this is just something that must be accepted as impossible.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Go get a book or a tutorial on printf() and read it. You're going to need to do so.

    %d is a placeholder for printing an integer, which is specified after the string of text. It's a control code. Anything followed by a % sign in a printf is special. Here, read this:

    and this:

    and this:

    and, heck, read this too:

    If you don't get it after that, read more of these:

    and if that still doesn't cut it for you... well,

  3. #3
    Registered User
    Join Date
    May 2003
    You obviously dont understand what I'm saying then if you think i have no clue what the %d does.

    The effect I'm trying to get to is how you can change the "{" and "}" into the words BEGIN and END.

    Such as
    #define BEGIN {
    #define END }
    int main()
    blah blah blah
    What I am trying to is this
    #define Q %d
    int main()
               x = 2;
               printf("Q", x);
    If no one still doesn't understand what I'm talking about, I'll just walk this way like nothing happened...

  4. #4
    Registered User
    Join Date
    May 2003
    Oh, belive me. I would never actually use things like BEGIN and END in replace of brackets, or any other significant functions or anything.

    Its just this program I am writing would have seemed easier if i could replace %d with a single letter (making image out of letters, maybe you can understand my viewpoint now), but now that i look on it, easier to just stick with the %d.

    Just thought it could of been the only worth while usage for it, but it proved me wrong. Defining your own statements suck.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IF CONDITION plese help
    By birumut in forum C Programming
    Replies: 12
    Last Post: 03-06-2009, 09:48 PM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  3. Double to Int conversion warning
    By wiznant in forum C Programming
    Replies: 15
    Last Post: 09-19-2005, 09:25 PM
  4. Help getting multiple keypresses in a DOS compiler
    By Nongan in forum Game Programming
    Replies: 2
    Last Post: 04-01-2005, 10:07 PM
  5. help with switch statements
    By Wexy in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 05:44 PM