Hi All,
I have written a program to input a decimal string and convert it to character string. Below is my program:
/*this program converts the decimal representation of an input string to character representation*/
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
char int2str(int n);
int main()
{
int dec[100]={0},i,j,decindex,ndec=0,nchar;
char character[100]={'\0'};
printf("Enter the input decimal sequence length\n");
scanf("%d",&ndec);
printf("Enter the input decimal sequence\n");
for(i=0;i<=nchar;i++)
{
scanf("%d",&j);
dec[i]=j;
}
/*This loop converts the decimal to character*/
for(i=0;i<=nchar;i++)
{
if(dec[i]!='.')
{
character[i]=int2str(dec[i]);
}
}
printf("The output sequence is");
for(i=0;i<=nchar;i++)
{
printf("%c",character[i]);
}
system("pause");
return 0;
}
/*this loop converts the decimal to character*/
char int2str(int n)
{
char c;
c=n+48;
return c;
}
On running the program, It doesn't proceed after entering the input decimal sequence. Kindly point out bugs/errors and suggest fixes. Thank you.