| | |
Cn't figure out error
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 34
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> #include <string> using namespace std; void writeArray(); void readArray(); const int capacity = 4; //const int spec = 4; double numbers[]={12456.89,234.00,3456.78,21212.50}; //string A12345; //string A45678; //string B21223; //string B21435; string names[]={"A12345","A45678","B21223","B21435"}; int main() { writeArray(); readArray(); } void readArray() { ifstream infile; infile.open ("accounts.txt"); infile >> numbers[capacity]; infile >> names[capacity]; cout << names[0] << endl; cout << numbers[0] << endl; cout << names[1] << endl; cout << numbers[1] << endl; cout << names[2] << endl; cout << numbers[2] << endl; cout << names[3] << endl; cout << numbers[3] << endl; infile.close(); } void writeArray() { ofstream outfile; outfile.open("accounts.txt"); outfile << numbers[capacity]; outfile << names[capacity]; outfile.close(); }
Can some1 please help, i can't figure what went wrong with my program!! I think it has something to do with string names array but don't know how to fix it!!
![]() |
Similar Threads
- C++ program error (C++)
- error help (C++)
- Error connecting to database (ASP.NET)
- LNK2019 Error (C++)
- Start Up Error Message and Problem Verification (OS 7 / 8 / 9)
- Cant figure this error out: "The page you requested, has produced an error" (ASP)
- IDE #1 Error after replacing DVD Drive (Storage)
Other Threads in the C++ Forum
- Previous Thread: Write text on top of Form
- Next Thread: Check the size of a file
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






