Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 14th, 2004, 10:07 PM   #11
jubbincake
Programmer
 
Join Date: Oct 2004
Posts: 63
Rep Power: 5 jubbincake is on a distinguished road
Benoit, wanna help me a bit? Maybe we can both learn from it.
jubbincake is offline   Reply With Quote
Old Oct 14th, 2004, 10:09 PM   #12
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5 Benoit is on a distinguished road
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
Benoit is offline   Reply With Quote
Old Oct 14th, 2004, 10:24 PM   #13
jubbincake
Programmer
 
Join Date: Oct 2004
Posts: 63
Rep Power: 5 jubbincake is on a distinguished road
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.
jubbincake is offline   Reply With Quote
Old Oct 14th, 2004, 10:28 PM   #14
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5 Benoit is on a distinguished road
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
Benoit is offline   Reply With Quote
Old Oct 14th, 2004, 10:30 PM   #15
jubbincake
Programmer
 
Join Date: Oct 2004
Posts: 63
Rep Power: 5 jubbincake is on a distinguished road
Yea, my msn is bishfrontsixgunswitchblade@hotmail.com, add me so we can discuss this further if you want.
jubbincake is offline   Reply With Quote
Old Oct 14th, 2004, 10:46 PM   #16
Daggerhex_Flynn
Programmer
 
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5 Daggerhex_Flynn is on a distinguished road
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.
Daggerhex_Flynn is offline   Reply With Quote
Old Oct 14th, 2004, 10:47 PM   #17
jubbincake
Programmer
 
Join Date: Oct 2004
Posts: 63
Rep Power: 5 jubbincake is on a distinguished road
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.
jubbincake is offline   Reply With Quote
Old Oct 14th, 2004, 11:13 PM   #18
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Oct 14th, 2004, 11:36 PM   #19
Daggerhex_Flynn
Programmer
 
Join Date: Oct 2004
Location: Canada
Posts: 82
Rep Power: 5 Daggerhex_Flynn is on a distinguished road
Quote:
Originally posted by jubbincake@Oct 15 2004, 02:47 AM
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.
C++ Primer 3rd edition will not show you how to use code like that, because the C++ commitee emphasises the standard library. The above code is how a C programmer might open a file and read text. A good book on C is called "Pointers on C" by Kenneth A. Reek, and "The C Programming Language" by D Ritchie.
Daggerhex_Flynn is offline   Reply With Quote
Old Oct 14th, 2004, 11:45 PM   #20
jubbincake
Programmer
 
Join Date: Oct 2004
Posts: 63
Rep Power: 5 jubbincake is on a distinguished road
but, I can do that stuff with C++ right, with the standard library?
jubbincake is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC