0
#include<stdio.h>
#include<stdlib.h>

int main()
{

int i,j;
int ascii_value;
char c;

FILE *plain;

plain=fopen("xx.dat","r");

while((c=getc(plain))!=EOF)
{
    ascii_value=c;
    printf("%d %c\n",ascii_value,c);
    printf("~~~~~~~~~~~~~~~~~~~~\n");
}

fclose(plain);
return 0;
}

the file xx.dat is 12sdfsldkfj
MY output is

49 1

50 2

115 s

100 d

102 f

115 s

108 l

100 d

107 k

102 f

106 j

10 

I am unable to understand why 10 in the last line is printed. Please help...Inline Code Example Here

3
Contributors
4
Replies
24
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
0

hi [mohit c]

I am unable to understand why 10 in the last line is printed. Please help...

Your input file has a blanck line (new line) after the the line 12sdfsldkfj i.e if the line of your input is 1, the blanck line is 2 remove it and you should be ok.

Or you test it, what is the ascii value for new line?

Edited by 2teez

0

I am still not able to understand what my input should be like? I entered this input without any blank lines and still 10 which is the ASCII value for a new line is printed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.