[code=cplusplus] int main() { string name; cout << "Please enter the filename of the encoded message:"; getline(cin,name); ifstream infile; infile.open(name.c_str()); if (infile.fail()) { cout << name << " fail to open." << endl; exit(1); } cout << name << endl; cout << " File successfully opened" << endl; string buffer; getline(infile, buffer); while ( !infile.eof() ) { cout << buffer << endl; } return 0; } [/code] Hi I'm making a program where the user types in the name of a file and displays the context of the file in the console window. I'm trying to use getline function to …

Member Avatar
Member Avatar
+0 forum 3

[code] //***************************************************************************** // CPSC1620 - Fall 2008 // // // Date: // Purpose: Program to perform array operations using functions //***************************************************************************** #include <iostream> using namespace std; //Prototype int readSeq(int []); int main() { return 0; } //***************************************************************************** //Function: readSeq //Assumption: Reads a sequence of integers //Action: Stores the sequence in the array given as parameter //***************************************************************************** int readSeq(int []) { } [/code] I'm not good with arrays I don't understand them. I have to make a function that reads squence of integers from the input and stores the sequence of numbers in the array give as a parameter. What would …

Member Avatar
Member Avatar
+0 forum 4

[code] #include <iostream> using namespace std; int main () { int j; int t; int p; int num; cout << " Please enter an even integer greater than 2: "; cin >> num; for ( int i = 2 ; i < num; i++ ) if ( ( i == 2 ) or ( i % 2 != 0 ) ) { p = i; } { for ( int j = 2; j > p; j++ ) if ( p % j != 0 ) t = p; cout << t << endl; } return 0; } [/code] I'm …

Member Avatar
Member Avatar
+0 forum 12

Ok so the code makes the user type in a number. Ok if the number is odd it must say "Invalid Input". If the number is EVEN it takes the ODD numbers of it and gives you the pairs that add up to the EVEN number. For example if I type 8 I want 8 = 1 + 7 8 = 3 + 5 how do I extract the digits? [code] #include <iostream> using namespace std; int main() { int q; int sum = 0; int num; cout << " Please enter a positive even interger "; cin >> num; …

Member Avatar
Member Avatar
+1 forum 3

The End.