Click here to Skip to main content
16,015,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys , i want to write a pogramme that convert all chars to int with a for loop , i don't know what to put in my char variable as a first value

What I have tried:

C++
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    char c ;
    c = 
    system("color a ");
    for(i=0;i<=255;i++)
    {
        printf("%c to int is : %d",c,c);
        printf("\n");
    }
    return 0;
}
Posted
Updated 21-Oct-17 19:45pm
v2

1 solution

Change your loop:
int main()
    {
    unsigned char c;
    for(c = 0; c != 255; c++)
        {
        printf("%c to int is : %d\n", c, (int) c);
        }
    return 0;
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900