how to convert an char array to decimal array

Answer Posted / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char a1[50];
int a2[50];
printf("enter the characters :");
gets(a1);
for(int i=0;a1[i]!='\0';i++)
a2[i]=(int)a1[i]; // TYPE CASTING
for(i=0;a1[i]!='\0';i++)
printf("%d",a2[i]);
getch();
}


thank you

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

the question is that what you have been doing all these periods (one year gap)

1617


What is indirection?

651


What is a structure and why it is used?

621


What does. int *x[](); means ?

637


How a string is stored in c?

589






while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

740


What is the difference between %d and %i?

596


Is array name a pointer?

605


Why flag is used in c?

651


How can you be sure that a program follows the ANSI C standard?

1127


Explain how can I read and write comma-delimited text?

654


What are dangling pointers in c?

641


Write the control statements in C language

650


What is an lvalue?

636


What are void pointers in c?

574