Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 01-18-2004, 11:09 PM   #1
Member (4 bit)
 
Join Date: Jan 2004
Location: Barrie
Posts: 8
Question How To Make Arrays,Loops and Files On C++

Could anyone please tell me how to make arrays loops and files on C++ I I have visual c++ and i need to know how to make them ASAP

email: clueleswonder69@hotmail.com
THANK YOU THANK YOU TO ANYONE WHO CAN HELP
troublewithc++ is offline   Reply With Quote
Old 01-19-2004, 08:30 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
as for array loops, I guess you want to ask how to loop through the variables of an array:
Code:
#include <iostream>
using namespace std;

#define SIZE 10

int main(void) {
    int array[SIZE]; // size is a const var or a define
    for (int i = 0; i < SIZE; i++) {
        cin >> array[i];
    }
}
as for how to work with files, it's very similar to cin/cout, you just need to create a file variable, and then use it exactly like cincout:
Code:
#include <iostream>
using namespace std;

int main(void) {
    ofstream file("myfile.txt") // for output
    int number = 5;
    file << number;
}
so class ifstream is for input (like cin), and class ofstream is for output (like cout), both require fstream to be included.
HTH

ps: what's the wrong with the boards so you want us to email you.

edit:
fixed < and >

Last edited by aym; 01-19-2004 at 08:40 AM.
aym is offline   Reply With Quote
Old 01-19-2004, 10:48 AM   #3
Member (4 bit)
 
Join Date: Jan 2004
Location: Barrie
Posts: 8
Thanks So much, i have to have this finished by the end of today.
troublewithc++ is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:45 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2