Lines in a C program
I am making a C program that prints the ASCII value of a string / text including spaces . The program works fine and gives the exact ASCII values โโof the string, including spaces, but the problem is that it also prints "10" at the end of all ASCII values.
This is my code:
#include<stdio.h>
#include<conio.h>
int main()
{
char str[100];
int i;
printf("Enter a string: ");
fgets(str,100,stdin);
//scanf("%s",str);
printf("String is: %s\n",str);
printf("ASCII value in Decimal is: ");
for(i=0; str[i]!='\0'; i++)
{
printf("%d ",str[i]);
}
printf("\n");
getch();
}
Please help me, tell me what the problem is and how to fix it. Thank you in advance.
+3
source to share