![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Oct 2004
Posts: 63
Rep Power: 5
![]() |
Benoit, wanna help me a bit? Maybe we can both learn from it.
|
|
|
|
|
|
#12 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5
![]() |
I dunno...I'm still a beginner in C
![]()
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Oct 2004
Posts: 63
Rep Power: 5
![]() |
Lol, ok we can learn together then, do you know file IO and generating randome numbers and stuff like that.. this can be as easy or as hard as we want it. So we can start with an easy outline, then like update with new things we learn and stuff like that.
|
|
|
|
|
|
#14 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5
![]() |
I haven't learned file I/O yet...I was playing around with Random numbers today. Do you have msn or AIM?
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#15 |
|
Programmer
Join Date: Oct 2004
Posts: 63
Rep Power: 5
![]() |
Yea, my msn is bishfrontsixgunswitchblade@hotmail.com, add me so we can discuss this further if you want.
|
|
|
|
|
|
#16 |
|
Programmer
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5
![]() |
Here is a basic way to read a file:
#include<stdio.h>
int main() {
FILE *fptr;
char buffer[255];
fptr = fopen("datafile","r");
while ( (fgets(buffer,255, fptr)) != NULL)
printf("%s", buffer);
fclose(fptr);
return 0;
}Here is a data file named datafile with a couple lines of text inside it. |
|
|
|
|
|
#17 |
|
Programmer
Join Date: Oct 2004
Posts: 63
Rep Power: 5
![]() |
Lol, thats a bit confusing man.. but im gonna get that one book you suggested, the 3rd edition one, so it wont be long before i understand it.
|
|
|
|
|
|
#18 |
|
Programming Guru
![]() ![]() ![]() |
I also wrote a few text-based games as the choose-your-own-adventure type... eventually turned them into MUDs... but now they cease to exist. It was rather fun though.
This a bit easier method, pulled from my file i/o library I wrote for college a long time ago: void GetFileContent (string strFile)
{
ifstream theFile(strFile.c_str());
string line;
while(!theFile.eof())
{
std::getline(theFile,line,'\n');
cout << line << endl;
}
}
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#19 | |
|
Programmer
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#20 |
|
Programmer
Join Date: Oct 2004
Posts: 63
Rep Power: 5
![]() |
but, I can do that stuff with C++ right, with the standard library?
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|