PLEASE HELP! this is not printing the ascii value of the character

#include<stdio.h>

int main(void) {
// your code goes here
int a[10],i,j;
char b[10];

scanf("%s",b);
for(j=0;j<10;j++)
{
    printf("%c\t",b[j]);
}
for(i=0;i<10;i++)
{
  a[i]='b[i]';
printf("%d\n",a[i]);
}

return 0;

}

A simple google search could have solved it also. :slight_smile:

In C language, you don’t need to put ’ ’ to typecast, you can just do,

a[i] = (int)b[i]

and since char is implicitly also promoted to int you may simply write

a[i] = b[i]

To know more about C datatypes type conversion, you can read here

I hope that answers your question :slight_smile:

2 Likes

thanks a lot!!!:grinning: