SRL Archive - C/C++ Help and Tutorials

C++ Questions


ZaSz

2009-06-29 08:33:01

Ok This is what I got
#define writeln(X) cout<<X<<"\n"
How would I make it actually kinda a variant like in scar?

^I posted it. That is pretty much a variant lol So no need for help there.

Also, how would I run command line commands??
^ fixed also


Unanswered questions:
I need help for this. (Issue is below
)
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
#include <stdlib.h>
#include <sys/stat.h>

#define writeln(X) cout<<X<<"\n"
#define userinput(question,storedvar) cout<<question<<":"; cin>> storedvar;

using namespace std;

bool FileExists(string strFilename) {
struct stat stFileInfo;
bool blnReturn;
int intStat;

intStat = stat(strFilename.c_str(),&stFileInfo);
if(intStat == 0) {
blnReturn = true;
} else {
blnReturn = false;
}

return(blnReturn);
}

int main()
{
string me;
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection does not exist. Downloading");
writeln("Srl is being downloaded. Please do not press keys or enter.");
writeln("It's common to get 1 svn write error.");
popen("svn checkout http://scardevreflection.googlecode.com/svn/trunk Includes/srl/SRL/reflection", "r");
Sleep(10000);
system("cls");
}
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection is yet to be downloaded. Try 1/6");
writeln("Waiting 10 seconds for try #2");
Sleep(10000);
system("cls");
}
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection is yet to be downloaded. Try 2/6");
writeln("Waiting 10 seconds for try #3");
Sleep(10000);
system("cls");
}
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection is yet to be downloaded. Try 3/6");
writeln("Waiting 10 seconds for try #4");
Sleep(10000);
system("cls");
}
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection is yet to be downloaded. Try 4/6");
writeln("Waiting 10 seconds for try #5");
Sleep(10000);
system("cls");
}
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection is yet to be downloaded. Try 5/6");
writeln("Waiting 10 seconds for try #6");
Sleep(10000);
system("cls");
}
if(!FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("Reflection is yet to be downloaded. Try 6/6");
writeln("Waiting 10 seconds to check the final time. ");
Sleep(10000);
system("cls");
}
if(FileExists("Includes/srl/SRL/reflection/RSBuild.txt")) {
writeln("It seems like Reflection Has downloaded Correctly");
} else {
writeln("Reflection Download Failed");
}
//cin.get();
}

It wont finish moving files until the end… It's not a timing issue. It just waits to the end… And my FileExist's works, ive tested on a fully downloaded reflection.

JAD

2009-06-29 09:08:14

I assume you don't need help with the writeln thing from what you said?

To be able to use command line c++ inputs, you need to have parameters on int main that the user can enter in the command prompt when calling the program. This is a popular way to declare main you may have seen/used already:


main(int argc,char *argv[])

This allows the user to input arguments for these 2 parameters that the program can then use.

Let me know if this helps or if you need anymore help.

ZaSz

2009-06-29 10:26:50

Yeah, my writeln doesn't need help.

Ty for your help, but after searching im using popen which is working quite well for my usage.

New question though - edited main post.

R0b0t1

2009-07-01 09:36:16

I think it's a function called FormatString or something, it works like printf.

Jackrawl

2009-07-04 04:06:53

Oh. Two things, I think. One the /'s need to be escaped, the other is that your .exe will not work unless it's placed beneath the Includes folder.

arash

2009-07-15 22:30:16

1.) I hate people who write code like script kiddies, learn to use iostream correctly and take advantage of "cout" it is much less process intensive.

2.) Why the fuck do you not use fstream to just check if a file exists, and is not corrupted, your check fails at the second part.

3.) Learn to code real C++, and do not waste peoples time with this garbage.

4.) You couldn't make your own class for this? Wow just Wow
#define writeln(X) cout<<X<<"\n"
#define userinput(question,storedvar) cout<<question<<":"; cin>> storedvar;

5.) Use a fucking array

Da 0wner

2009-07-15 22:33:44

From: arash
1.) I hate people who write code like script kiddies, learn to use iostream correctly and take advantage of "cout" it is much less process intensive.

2.) Why the fuck do you not use fstream to just check if a file exists, and is not corrupted, your check fails at the second part.

3.) Learn to code real C++, and do not waste peoples time with this garbage.

4.) You couldn't make your own class for this? Wow just Wow
#define writeln(X) cout<<X<<"\n"
#define userinput(question,storedvar) cout<<question<<":"; cin>> storedvar;

5.) Use a fucking array


What the hell? Don't be such a dick.

Edit: Btw, he's just starting to learn it..we all started there at one point.

ZaSz

2009-07-16 00:56:43

From: arash
1.) I hate people who write code like script kiddies, learn to use iostream correctly and take advantage of "cout" it is much less process intensive.

2.) Why the fuck do you not use fstream to just check if a file exists, and is not corrupted, your check fails at the second part.

3.) Learn to code real C++, and do not waste peoples time with this garbage.

4.) You couldn't make your own class for this? Wow just Wow
#define writeln(X) cout<<X<<"\n"
#define userinput(question,storedvar) cout<<question<<":"; cin>> storedvar;

5.) Use a fucking array


And yet, that didn't actually help me. All you just did was bitch. Bad attitude.