Thread: chars

  1. #1
    alanson
    Guest

    Exclamation chars

    How can I make a "char loop"? I mean, a programm that writes all chars from a to z. Do I have to make it with for loop or how? Is there a possibility to make that with enum? Write your solutions.
    Thx in advance
    ALan

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    for( char cValue = 'a'; cValue <= 'z'; cValue++ )
        cout << cValue << endl;
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User raimo's Avatar
    Join Date
    Jun 2002
    Posts
    107

    Re: chars

    >How can I make a "char loop"? I mean, a programm that writes all chars from a to z.
    >

    With ASCII it is quite easy.

    >Do I have to make it with for loop or how? Is there a possibility to make that with enum?

    No, you do not have to

    >Write your solutions.
    >Thx in advance

    Code:
    #include <iostream>
    int main (){
      for(int i='a';i<='z';i++)
          std::cout<<(char)i;
      return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. while condition question..
    By transgalactic2 in forum C Programming
    Replies: 3
    Last Post: 04-04-2009, 04:49 PM
  2. Counting how many chars in a string
    By tigs in forum C Programming
    Replies: 4
    Last Post: 08-05-2002, 12:25 AM
  3. really got stuck with unsigned chars
    By Abdi in forum C Programming
    Replies: 7
    Last Post: 06-11-2002, 12:47 PM
  4. move chars position
    By SpuRky in forum C Programming
    Replies: 3
    Last Post: 06-09-2002, 02:59 AM
  5. fancy strcpy
    By heat511 in forum C++ Programming
    Replies: 34
    Last Post: 05-01-2002, 04:29 PM