Greetings!
Just wanna ask a sample program for visual c++.
Thanks
Best regards,
glenndr_15
#include <iostream>
int main(int argc,char**argv)
{
std::cout << "Hello World ! << std::endl;
return 0;
}
google for Visual C++ sample programs,
http://lmgtfy.com/?q=visual+C%2B%2B+sample+programs
Missed the end quote so that would return an error.
Missed the end quote so that would return an error.
yeah !
std::cout << "Hello World !" << std::endl;
It should be corrected !
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
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;
}
@blitter: If you want to post code like that at least make it a complete function.
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() {
//...
}
>>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.
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...
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.
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");
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.