Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

ASCII characters in C++...

  • 18-02-2002 04:12PM
    #1
    Posts: 431 ✭✭


    This might seem like a completely stupid question but can anyone tell me how to print out ASCII characters in C/C++?

    Will i have to access the registers immediately to select which one i want or is there another way to do this?

    Thanks for any help:)


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    You were not quite specific on your exact query, but a simple program in C such as



    int main()

    {

    int i=32;

    for(i=32;i<255;i++)

    printf("%c",i);

    }



    Will print out all the ascii chars from 32-255. Is that what you are trying too do??


  • Posts: 431 ✭✭ [Deleted User]


    Yeah, i just wanted to print out, say if i wanted that ASCII smiley face...how would i select the individual code to do it...but you've given me the solution with that last post so thanks!
    :)


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    int main()
    {
    int i=32;
    for(i=32;i<255;i++)
    printf("%c",i);
    }

    should the above code not be
    int main()
    {
    int i=32;
    for(i=32;i<256;i++)
    printf("%c",i);
    }

    ?????


  • Registered Users, Registered Users 2 Posts: 16,415 ✭✭✭✭Trojan


    It's an error alright, it's also incorrect to specify "int main()" without a return line (should be void), but it's kinda irrelevant isn't it? He got the general idea...





    Al.


Advertisement