Click here to Skip to main content
15,889,878 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SHFileOperation and Vista64 Pin
khb28-Jun-09 22:38
khb28-Jun-09 22:38 
GeneralRe: SHFileOperation and Vista64 Pin
«_Superman_»28-Jun-09 22:39
professional«_Superman_»28-Jun-09 22:39 
GeneralRe: SHFileOperation and Vista64 Pin
khb28-Jun-09 22:48
khb28-Jun-09 22:48 
GeneralRe: SHFileOperation and Vista64 Pin
«_Superman_»28-Jun-09 22:51
professional«_Superman_»28-Jun-09 22:51 
GeneralRe: SHFileOperation and Vista64 Pin
khb28-Jun-09 23:06
khb28-Jun-09 23:06 
GeneralRe: SHFileOperation and Vista64 Pin
Randor 29-Jun-09 5:03
professional Randor 29-Jun-09 5:03 
GeneralRe: SHFileOperation and Vista64 Pin
khb29-Jun-09 5:14
khb29-Jun-09 5:14 
QuestionHow to remove the carriage return to newline conversion in C. Pin
Razanust28-Jun-09 20:05
Razanust28-Jun-09 20:05 
oBJECT:
To copy the data stored in a file along with their respective line numbers.

CODE:

#include<stdio>
#include<string>
#include<stdlib>
main()
{
int lno=1,n=0,x=1;
char ch[80];
FILE*fp;
fp=fopen("imp.txt","rb");

if (fp==NULL)
{puts("Cannot open file");
exit(1);}
printf("01 ");

while(1)
{
ch[n]=fgetc(fp);
n=n+1;

if (ch[n-1]==EOF)
break;
else if (ch[n-1]!='\r')
{
printf("%c",ch[n-1]);}
else if (ch[n-1]=='\r')
{x=x+1;
printf("\n0%d ",x);}
}
fclose(fp);
}


DATA STORED IN THE FILE:
hello raza here
how are you


PROBLEM:
Output is coming to be as following.

01 hello raza here
02
how are you

It should be
01 hello raza here
02 how are you

Now although i am reading the file in the binary mode, even then it is converting the
carriage returns into new lines! Why?

Also when i open the file in text mode the output is

01 hello raza here
how are you
AnswerRe: How to remove the carriage return to newline conversion in C. Pin
khb28-Jun-09 22:08
khb28-Jun-09 22:08 
AnswerRe: How to remove the carriage return to newline conversion in C. Pin
Rajesh R Subramanian28-Jun-09 22:14
professionalRajesh R Subramanian28-Jun-09 22:14 
QuestionHow to find Number of processor or Cores ? Pin
ERLN28-Jun-09 20:04
ERLN28-Jun-09 20:04 
AnswerRe: How to find Number of processor or Cores ? Pin
«_Superman_»28-Jun-09 22:17
professional«_Superman_»28-Jun-09 22:17 
GeneralRe: How to find Number of processor or Cores ? Pin
ERLN28-Jun-09 23:26
ERLN28-Jun-09 23:26 
GeneralRe: How to find Number of processor or Cores ? Pin
«_Superman_»28-Jun-09 23:32
professional«_Superman_»28-Jun-09 23:32 
QuestionRe: How to find Number of processor or Cores ? Pin
ERLN28-Jun-09 23:42
ERLN28-Jun-09 23:42 
AnswerRe: How to find Number of processor or Cores ? Pin
«_Superman_»28-Jun-09 23:44
professional«_Superman_»28-Jun-09 23:44 
GeneralRe: How to find Number of processor or Cores ? Pin
ERLN29-Jun-09 0:00
ERLN29-Jun-09 0:00 
GeneralRe: How to find Number of processor or Cores ? Pin
Stuart Dootson29-Jun-09 0:05
professionalStuart Dootson29-Jun-09 0:05 
GeneralRe: How to find Number of processor or Cores ? Pin
«_Superman_»29-Jun-09 0:06
professional«_Superman_»29-Jun-09 0:06 
AnswerRe: How to find Number of processor or Cores ? Pin
Stuart Dootson29-Jun-09 0:01
professionalStuart Dootson29-Jun-09 0:01 
GeneralRe: How to find Number of processor or Cores ? Pin
ERLN29-Jun-09 0:35
ERLN29-Jun-09 0:35 
GeneralRe: How to find Number of processor or Cores ? Pin
Stuart Dootson29-Jun-09 0:42
professionalStuart Dootson29-Jun-09 0:42 
AnswerRe: How to find Number of processor or Cores ? Pin
Randor 29-Jun-09 4:11
professional Randor 29-Jun-09 4:11 
Questionneed help of c code of imresize matlab function Pin
ashish_2418828-Jun-09 19:42
ashish_2418828-Jun-09 19:42 
AnswerRe: need help of c code of imresize matlab function Pin
chandu00428-Jun-09 20:38
chandu00428-Jun-09 20:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.