Click here to Skip to main content
15,911,360 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Tcp/Ip send() does sometimes not succeed Pin
Mark Salsbery26-Jan-07 7:50
Mark Salsbery26-Jan-07 7:50 
GeneralRe: Tcp/Ip send() does sometimes not succeed Pin
Mike O'Neill26-Jan-07 10:33
Mike O'Neill26-Jan-07 10:33 
GeneralRe: Tcp/Ip send() does sometimes not succeed Pin
Mark Salsbery26-Jan-07 10:42
Mark Salsbery26-Jan-07 10:42 
GeneralRe: Tcp/Ip send() does sometimes not succeed Pin
Mark Salsbery26-Jan-07 10:47
Mark Salsbery26-Jan-07 10:47 
AnswerRe: Tcp/Ip send() does sometimes not succeed [modified] Pin
Eytukan26-Jan-07 7:11
Eytukan26-Jan-07 7:11 
GeneralRe: Tcp/Ip send() does sometimes not succeed Pin
Mark Salsbery26-Jan-07 7:15
Mark Salsbery26-Jan-07 7:15 
GeneralRe: Tcp/Ip send() does sometimes not succeed Pin
Eytukan26-Jan-07 7:18
Eytukan26-Jan-07 7:18 
QuestionFile format [modified] Pin
dellthinker26-Jan-07 5:43
dellthinker26-Jan-07 5:43 
Hi all. Im having trouble making this file read-out look nice.

The code is this:

<br />
#include <fstream><br />
using namespace std;<br />
<br />
int main(){<br />
	char buffer[100];<br />
	ifstream file("file.dat",ios::end);<br />
	if(file.fail()){<br />
	printf("File not found.\n");<br />
	}<br />
	printf("File contents read the following:\n");<br />
	while(file >> buffer){<br />
	printf("\n%s ",buffer);<br />
	}<br />
	file.close();<br />
	system("pause");<br />
	return 0;<br />
}<br />


The file "file.dat" reads "This is only a test" inside. But when i run the program it reads:
File contents read the following:

This
is
only
a
test
-----------------------

So i figured maybe it was a problem with my way of printing the message in the console. So i switched the printf around from this

<br />
printf("\n%s ",buffer);<br />


To this
<br />
printf("%s\n ",buffer);<br />


To this
<br />
printf("%s",buffer); // This putsallthewordstogetherlikeso<br />


And still cant come up with a better looking format. Is there another way i can make it print the way its saved in the file? Thanx in advance!

P.S.

If i made the print like this: printf("%s ",buffer); It would print the first line in the file as its written in the file. But if there were two lines or three etc. It prints it like this

"This is only a test This is only a test This is only a test"

Which isnt what im looking to do. I'd like it look something like

This is only a test
This is only a test
This is only a test
AnswerRe: File format Pin
Reagan Conservative26-Jan-07 6:02
Reagan Conservative26-Jan-07 6:02 
GeneralRe: File format Pin
David Crow26-Jan-07 6:13
David Crow26-Jan-07 6:13 
AnswerRe: File format Pin
David Crow26-Jan-07 6:15
David Crow26-Jan-07 6:15 
AnswerRe: File format Pin
Michał Zalewski26-Jan-07 9:49
Michał Zalewski26-Jan-07 9:49 
QuestionSelect User dialog Pin
Ami Bar26-Jan-07 5:04
Ami Bar26-Jan-07 5:04 
QuestionRe: Select User dialog Pin
David Crow26-Jan-07 6:10
David Crow26-Jan-07 6:10 
GeneralRe: Select User dialog Pin
Ami Bar26-Jan-07 9:01
Ami Bar26-Jan-07 9:01 
GeneralRe: Select User dialog Pin
David Crow26-Jan-07 9:14
David Crow26-Jan-07 9:14 
GeneralRe: Select User dialog Pin
Ami Bar26-Jan-07 9:19
Ami Bar26-Jan-07 9:19 
GeneralRe: Select User dialog Pin
Mark Salsbery26-Jan-07 9:47
Mark Salsbery26-Jan-07 9:47 
GeneralRe: Select User dialog Pin
Ami Bar26-Jan-07 9:52
Ami Bar26-Jan-07 9:52 
QuestionRe: Select User dialog Pin
David Crow26-Jan-07 10:28
David Crow26-Jan-07 10:28 
AnswerRe: Select User dialog Pin
Ami Bar26-Jan-07 10:36
Ami Bar26-Jan-07 10:36 
QuestionHow template in C++ Work ? Pin
Yanshof26-Jan-07 4:56
Yanshof26-Jan-07 4:56 
AnswerRe: How template in C++ Work ? Pin
Reagan Conservative26-Jan-07 6:08
Reagan Conservative26-Jan-07 6:08 
AnswerRe: How template in C++ Work ? Pin
Waldermort26-Jan-07 7:02
Waldermort26-Jan-07 7:02 
AnswerRe: How template in C++ Work ? Pin
Eytukan26-Jan-07 7:04
Eytukan26-Jan-07 7:04 

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.