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

Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

601


Why do we use & in c?

587


What is the most efficient way to store flag values?

683


How can I send mail from within a c program?

577


What is a pragma?

666






Why c is called free form language?

566


Write a program to find factorial of a number using recursive function.

639


How can you check to see whether a symbol is defined?

585


List the difference between a "copy constructor" and a "assignment operator"?

578


what is the difference between class and unio?

1854


write a c program in such a way that if we enter the today date the output should be next day's date.

1677


What is the difference between c &c++?

643


Are the variables argc and argv are local to main?

783


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

640


Define the scope of static variables.

602