Define statements conflicting with printf...

This is a discussion on Define statements conflicting with printf... within the C Programming forums, part of the General Programming Boards category; Problem goes out like this. I want to replace the %d with, say, letter Q. Problem is, when I use ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    25

    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
    Posts
    1,916
    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:

    http://msdn.microsoft.com/library/de...tf_wprintf.asp

    and this:
    http://msdn.microsoft.com/library/de..._functions.asp

    and this:
    http://cplus.about.com/library/weekly/aa032302a.htm

    and, heck, read this too:
    http://www.cs.utah.edu/~zachary/ispm...als/io/io.html

    If you don't get it after that, read more of these:
    http://www.google.com/search?sourcei...rintf+tutorial

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

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    25
    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
    Code:
    #define BEGIN {
    #define END }
    
    int main()
    
    BEGIN
    
    blah blah blah
    
    END
    What I am trying to is this
    Code:
    #define Q %d
    
    int main()
    {
               x = 2;
               
               printf("Q", x);
           
               yadayadayada
    }
    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
    Posts
    25
    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, 08:48 PM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 08: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, 09:07 PM
  5. help with switch statements
    By Wexy in forum C Programming
    Replies: 3
    Last Post: 11-06-2002, 04:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21