quick question (adding characters)

This is a discussion on quick question (adding characters) within the C Programming forums, part of the General Programming Boards category; Quick question: How do you add more characters onto a string? eg, I want to convert an int number into ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    4

    quick question (adding characters)

    Quick question:

    How do you add more characters onto a string?

    eg,

    I want to convert an int number into a number of chars equal to that int number:

    number = 3 converts to '$$$'
    number = 5 converts to '$$$$$'
    number = 0 converts to ''

    I also want all the $'s to be stored in a variable rather than print them all out one by one.

    So I have my code set up into a loop with it ending at number and in every repitition it adds another $ to the result. I just don't know the syntax to adding charcaters. Thanks

  2. #2
    Registered User
    Join Date
    Sep 2005
    Posts
    4
    nevermind, I figured it out. I am now confused in how to printf that char result if I need to. Anyone know? I guess, Im just going to have to learn about typecasting ignore this post thx
    Last edited by Cactus; 09-24-2005 at 03:53 PM.

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by Cactus
    nevermind, I figured it out. I am now confused in how to printf that char result if I need to. Anyone know?
    try
    Code:
    printf("%s\n", your_string);
    Or, if you are just needing to output the string, and nothing else, consider the puts() function:

    Code:
    puts(your_string);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quick question (C/C++)
    By owi_just in forum C Programming
    Replies: 2
    Last Post: 03-19-2005, 08:44 AM
  2. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  3. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  4. Quick Question on File Names and Directories
    By Kyoto Oshiro in forum C++ Programming
    Replies: 4
    Last Post: 03-29-2002, 01:54 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

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