81 Archived Topics
Remove Filter #include <iostream> #include <stdio.h> #include <fstream> #include <string> using namespace std; int main() { int number_Of_Lines_To_Print_From_End=0; char file_name[20]; streampos length; cout<<"enter file name that needs to be opened\n"; cin>>file_name; cout<<"enter number of lines to print from end of file\n"; cin>>number_Of_Lines_To_Print_From_End; fstream file; file.open(file_name, ios::out ); if(file.is_open()) { cout<<"the file opened\n"; … | |
In unix if you create and open a file by using 9 digits numbers in the open function it seems to work but in C++ you only don't have a parameter to do that rather you have ios_base. Just wondering if there are owner,group and world settings that can be … | |
O_RWDR opens a file for read and write and pmode allows you to specify permission for each of the users? WHAT DOES IT MEAN BY WHAT PMODES AND O_RDWR ARE AVALABLE ON YOUR SYSTEM? CONSIDERING I AM USING VISTA I HAVE NO IDEA. I HAVE THE ABILITY TO READ AND … | |
show_int_vector method RETURNS MEMORY LOCATION FOR EVERTHING EXCEPT FOR LAST VALUE. main [code] #include "my_int_vector.h" #include <iostream> using namespace std; int main() { my_int_vector b(0); b.push_back(10); //b.show_int_vector(b); b.push_back(122); b.show_int_vector(b); //b.push_back(20000); return 0; } [/code] Interface [code] class my_int_vector { public: //constructor to create an array my_int_vector(int intial); //prints out the … | |
and how i would go about fixing it? main [code] #include <iostream> #include "Format.h" #include <fstream> using namespace std; int main() { Format format; //string word; char in; ifstream infile; bool a=true; bool b=true; bool c=true; while(b==true) { cout<<"to quit type 'q'\n" <<"enter 'c' to get from console\n" <<"enter 'f' … | |
Random numbers appear and i have no idea where they are appearing from. Problem is in << operator. Not sure how to fix it. Main #include <iostream> #include "Format.h" using namespace std; int main() { Format format; format.setJustification('l'); format.add_word("one"); format.add_word("two"); format.add_word("is"); cout<<format; return 0; } Implementation #include "Format.h" #include <vector> … | |
word is a private variable. MAin [code] #include <iostream> #include "FrameThePhrase.h" using namespace std; int main() { Frame_The_Phrase frame; char in; ifstream input; bool a=true; bool b=true; bool c=true; string length; while(b==true) { cout<<"to quit type 'q'\n" <<"enter 'c' to get from console\n" <<"enter 'f' to get from file\n"; cin>>in; … | |
Here is a link to the actual project. I could easily use getline for the phrase. Don't need to overload it to read in phrase. [url]http://home.earthlink.net/~craie/122/projects/framed.phrase.html[/url] | |
Please explain. Does it automatically include the default constructor? | |
I understand the concept but i don't know when to use and what my teacher expects when he says overload certain operators. | |
When you use getline(input,inputline) and you delete part of the inputline does it also ignore from the input file? | |
IT is defined in the back of my book but can't be found in my program. | |
ITS ALL THE WAY AT THE BOTTOM OF MY IMPLEMENTATION FILE. MAIN [code] #include <iostream> #include <fstream> #include "line_test.h" using namespace std; int main() { //open up file to be read string input; ifstream in; cout<<"enter file name which needs to be opened\n"; cin>>input; in.open(input.c_str()); while(!in) { in.close(); cout<<"the input … | |
why do i get undefined reference to error in my main with regards to isvalidname. It says undefined reference to... in my isvalidname i check if they enter in first name, char ws and then last name. Then i want to print out everything that i have deleted on that … | |
gives me error main /* The purpose of this lab is to open a text file and then make a copy of it */ #include <iostream> #include <fstream> #include "Interface.h" using namespace std; int main() { //open up file to be read from string input; ifstream in; cout<<"enter file name … | |
i am supposed to make 2 functions called find and they are supposed to find a character or string if they are similar when i do this progam gives me weird error: "use of search ambigious" "first declared as class search here. //main [code] #include <iostream> #include <cstdlib> using namespace … | |
it needs to make sure numbers aren't duplicate and are ordered. maybe change my cout statements to arrays? Thanks. This is what program is supposed to do input Q 1,2,3-5,6-7 output do problem 1,2,3,4,5,6,7 of Q. [code] #include <iostream> #include <cstdlib> #include <sstream> #include <string> using namespace std; int main() … | |
here's my code, don't see why it doesn't print out [code] #include <iostream> using namespace std; int main() { cout<<"enter a passage into input to find out how difficult it is to read\n"; string passage; cin>>passage; char letter; int space=0; while(letter!='\n') { if(isspace(cin.peek())&&letter=='\n') { cout<<"from space"; space=space++; } } cout<< … | |
so input would be Q1,2,3-5 output would be do problems 1,2,3,4,5 of Q [code] #include <iostream> #include <cstdlib> #include <sstream> #include <string> using namespace std; int main() { cout <<"enter the problemset and number""\n"; //problems represents name and numbers string problems; char quote; char num; string number; //gather name if(cin.peek()=='"' … | |
i have created a C string of my variables and guessing i need some king of loop to check each character after it gets it? | |
so i find the period or whatever the sentence ends in. Then I create a substring from that and delete the part which contains the end character. Then i keep count of it. | |
//main [code] #include <iostream> #include <cstdlib> using namespace std; #include "libro.h" int main() { test ab; cout<<"enter width limit"; int length; cin>>length; ab.alternate(length); } [/code] //implementation [code] #include <iostream> #include <cctype> #include <cstdlib> using namespace std; #include "libro.h" int test::alternate(int width) { //for odd, 3 char-ellipsis if(width%2==1) { keep=width-3; } … | |
the error is on line 32 of my main program //interface file [code] #ifndef STREXTRA_H_INCLUDED #define STREXTRA_H_INCLUDED #include <iostream> using namespace std; class search { public: int find(unsigned char mystring,char letter); int find(char mystring[],string word); }; #endif // STREXTRA_H_INCLUDED [/code] //implementation [code] #include <iostream> #include <cstdlib> using namespace std; #include … | |
its in the num=="-". [code] #include <iostream> #include <cstdlib> using namespace std; int main() { cout <<"enter the problemset and number""\n"; //problems represents name and numbers string problems; char quote; char num; string number; //gather name if(cin.peek()=='"' || cin.peek() == ''') { cin >>quote; getline(cin,problems,quote); } else { while (!isdigit(cin.peek()) … | |
[code] #include <iostream> #include <cstdlib> using namespace std; int main() { cout <<"enter the problemset and number""\n"; //problems represents name and numbers string problems , probtitle; string xx; bool x=true; char quote; string str1, str2; string begin; //gather name if(cin.peek()=='"' || cin.peek() == ''') { cin >>quote; getline(cin,problems,quote); } else … | |
if it contains quote it cuts it out, then i am stuck on part when i just enter in a problemset without a quote or single quote. Then it doesn't gather numbers correctly but stores the entire string [code] int main() { cout <<"enter the problemset and number""\n"; //problems represents … | |
[code] #include <iostream> using namespace std; #include "Interface.h" #include <conio.h> int main() { apple t; bool quit = false; while(! quit) { cout<<"the original value at beginning of clock is\n"<<clock()<<"\n"; t.start(); cout<<"hit enter when you want to stop timer\n"; if(cin.get()=='\n') { t.end(); int time =t.elapsed(); cout<<"the time difference is\n"<<time<<"\n"; cout<<"enter … | |
[CODE] Implementation file using namespace std; #include "Interface.h" #include <time.h> void timer::start() { if(! running) { begin=(unsigned int) clock(); running=true; } } void timer::end() { if(running) { finish=(unsigned int) clock(); running=false; } } int timer::elapsed() { if(running) { return((unsigned int) clock()-begin); } else { return finish-begin; } } int timer::output(unsigned … | |
Here are my 3 files interface file #ifndef INTERFACE_H_INCLUDED #define INTERFACE_H_INCLUDED #include <time.h> class timer { public: void start(); void end(); int elapsed(); int subtract(); int add(); int output(unsigned int seconds); private: bool running; int begin; int finish; }; #endif // INTERFACE_H_INCLUDED implementation file using namespace std; #include "Interface.h" #include … | |
[code=cplusplus]#include <iostream> #include <cstdlib> using namespace std; int main() { cout <<"enter the problemset and number""\n"; //problems represents name and numbers string problems; string problem_name_and_numbers=problems; string numbers; char quote; int total_length=problems.length(); //gather name if(cin.peek()=='"' || cin.peek() == ''') { cin >>quote; getline(cin,problems,quote); int problemslength=(problems.length()+1); int difference=total_length-problemlength; numbers=problem_name_and_numbers.substr(problemlength,difference); } else { … | |
how can i cast a string to int when i have this [code=cplusplus] //input problem numbers cout<<"\n""enter the numbers"; //numbers represents what they input string numbers; getline(cin,numbers); //position represents at what location value comma is int position; while(numbers.find(',') !=string::npos) { //print out what the user inputs //used to split up … |
The End.