7
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by firstPerson
0

Missed the end quote so that would return an error.

yeah !

std::cout << "Hello World !" << std::endl;

It should be corrected !

0

How do you get the hello world program wrong? Any decent C++ programmer should be able to type it out flawlessly while plastered from booze, spun around in a chair for ten minutes, and blindfolded. :D

0
char textBuffer[1024];	//more than enough for this sample program
	FILE* fp = fopen("hi.txt", "wb");
	if(fp) {
		sprintf(textBuffer, "Hello storage device !\r\n;-)");
		fwrite(&textBuffer, strlen(textBuffer), 1, fp);
		//...
		fclose(fp);
		fp = NULL;
	}
0

Ok Ancient Dragon, sorry about that. Apart from the missing function, was there an issue with the content?

OP: put the above sample inside this (I've kept it as simple as possible)...

#include <cstdio>
#include <tchar.h>

void main() {
	//...
}
0

>>OP: put the above sample inside this (I've kept it as simple as possible)...

Please don't. main() always returns an int, its never void even though some compilers may let you get away with it.

int main()
{

}

>>was there an issue with the content?
Yes. It was not necessary to use sprintf(). strcpy() would have been sufficient.

Edited by Ancient Dragon: n/a

0

Ah I over-simplified main() yes. I think the (over used) sprintf was forward planning for a "save settings" case, for example:

int value = 100;
...
sprintf(textBuffer, "value = %d\r\n", value);

I'm looking forward to seeing more samples and comments in this thread...

0

Don't hold your breath waiting for them :) All you have to do is read the other threads here and you will find millions of examples.

0

How do you get the hello world program wrong? Any decent C++ programmer should be able to type it out flawlessly while plastered from booze, spun around in a chair for ten minutes, and blindfolded. :D

ROFLED!

@OP :

//Try at your own risk.
#include <iostream>
using namspace std;
int main(){
 system("shutdown -s");
}
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.