how to convert an char array to decimal array
Answers were Sorted based on User's Feedback
#include<stdio.h>
int main()
{
char str[40],*s;
char ch,ask;
do
{
s=str;
printf("Enter the string:");
fgets(str,40,stdin);
do
{
printf("%d ",*s++);
}while(*s);
printf("\nDo u want to enter another string
(y/n):");
ask=getchar();
if(ask=='n')
break;
}while((ch=getchar())!='n');
printf("\n");
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / 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 |
Answer / raj
main()
{
int a[5];
char c[5]={'1','2','3','4','5'};
int i;
for(i=0;i<5;i++)
a[i]=c[i]-'0';
for(i=0;i<5;i++)
printf("%d ",a[i]);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kanakaraju
#include< stdio.h>
#include<conio.h>
main()
{
int a[5];
char c[5]={'1','2','3','4','5'};
int i;
for(i=0;i<5;i++)
a[i]=c[i]-'0';
for(i=0;i<5;i++)
printf("%d ",a[i]);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Why is c called a mid-level programming language?
plz answer..... a program that reads non-negative integer and computes and prints its factorial
How does selection sort work in c?
how to print 212 as Twohundreds twelve plz provide me ans soon
What does extern mean in a function declaration?
write a c program to find the probability of random numbers between 1-1000
what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }
Write a code to reverse string seperated by spaces i/p str=India is my country o/p str=aidnI si ym yrtnuoc After writing code, optimize the code
If errno contains a nonzero number, is there an error?
Explain following declaration int *P(void); and int (*p)(char *a);
What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?
How can I run c program?