diff --git a/ch17/17_37_38/17_37_38.cpp b/ch17/17_37_38/17_37_38.cpp index aa6cc70c..6cab2a1b 100644 --- a/ch17/17_37_38/17_37_38.cpp +++ b/ch17/17_37_38/17_37_38.cpp @@ -11,33 +11,42 @@ using namespace std; -int main () { - ifstream myfile ("test.txt"); - char sink [250]; - - while(myfile.getline(sink,250)) - { - cout << sink << endl; - } - return 0; -} +//int main () { +// ifstream myfile("F:\\Git\\Cpp-Primer\\ch17\\17_37_38\\test.txt"); +// if (myfile) cout << 1 << endl; +// char sink [250]; +// +// while(myfile.getline(sink,250)) +// { +// cout << sink << endl; +// } +// return 0; +//} //17.38 //Extend your program from the previous exercise to print each word you read onto its own line. -#include -#include -#include - -using namespace std; - -int main () { - ifstream myfile ("test.txt"); - char sink [250]; - - while(myfile.getline(sink,250,' ')) - { - cout << sink << endl; - } - return 0; +//#include +//#include +//#include +// +//using namespace std; +// +//int main () { +// ifstream myfile ("F:\\Git\\Cpp-Primer\\ch17\\17_37_38\\test.txt"); +// char sink [250]; +// +// while(myfile.getline(sink,250,' ')) +// { +// cout << sink << endl; +// } +// return 0; +//} + + +int main() +{ + std::cout << "Standard Output!\n"; + std::cerr << "Standard Error!\n"; + std::clog << "Standard Log??\n"; } diff --git a/ch17/17_37_38/test.txt b/ch17/17_37_38/test.txt index c196c2df..b0219f50 100644 --- a/ch17/17_37_38/test.txt +++ b/ch17/17_37_38/test.txt @@ -6,6 +6,8 @@ I'm droppin' flava, my behaviour is heriditery, But my technique is very necessary. Blame it on Ice Cube... Because he says it gets funky When you got a subject and a predacit. + + Add it on a dope beat And that'll make you think. Some suckaz just tickle me pink diff --git a/ch17/ex17_28_29_30.cpp b/ch17/ex17_28_29_30.cpp index 2e841e91..42807f2e 100644 --- a/ch17/ex17_28_29_30.cpp +++ b/ch17/ex17_28_29_30.cpp @@ -21,6 +21,7 @@ #include #include +#include // default version unsigned random_gen(); diff --git a/ch17/ex17_33.cpp b/ch17/ex17_33.cpp index e916c2b8..e7f80197 100644 --- a/ch17/ex17_33.cpp +++ b/ch17/ex17_33.cpp @@ -47,7 +47,7 @@ int main() { // sort words in vector sort(dict.begin(), dict.end(), [](const ps &_ps1, const ps &_ps2){ return _ps1.first < _ps2.first; }); i.open("i.txt"); - default_random_engine e(time(0)); + default_random_engine e(unsigned int(time(0))); // read words from text while (i >> str1) { // find word in dictionary diff --git a/ch18/18_18 18_19.cpp b/ch18/18_18 18_19.cpp index f3f1b3b3..2ccaee79 100644 --- a/ch18/18_18 18_19.cpp +++ b/ch18/18_18 18_19.cpp @@ -16,7 +16,7 @@ void swap(T v1,Tv2) //By stating we are using std::swap all the following uses of swap in the scope of the function will //look for the matching template for its argument types in the standard library. //If mem1 is a string the program will use the standard library function that has string arguments. -//If mem1 is int, it will use the standard library template version wit int arguments. +//If mem1 is int, it will use the standard library template version with int arguments. //18.19 diff --git a/ch18/18_20.cpp b/ch18/18_20.cpp index 86f2460a..bfead927 100644 --- a/ch18/18_20.cpp +++ b/ch18/18_20.cpp @@ -4,34 +4,32 @@ //In the following code, determine which function, if any, matches the call to compute, List the candidate and viable functions. //What type conversions, if any, are applied to the argument to match the parameter in each viable function. -//void conpute int first, no type conversion +//void compute(int) first, no type conversion //void const void works. -//void compute() doesnt work +//void compute() doesn't work //double double works converted to double //char char works - - - -//std::cout< namespace primerLib { void compute(); //Error, does not work. Too many argument in the call to match. - void compute( const void *); //Works! Converts argument to a constant void pointer. + void compute(const void *) {}; //Works! Converts argument to a constant void pointer. } -using primerLib::compute; -void compute(int);//Works! Most closely matches the argument parameters so it is selected first. + +void compute(int) { std::cout << "compute(int)" << std::endl; };//Works! Most closely matches the argument parameters so it is selected first. void compute(double, double =3.4);//Works! Converts argument to double. void compute(char* x,char* =0);//Works! converts to a character pointer. void f() { + using primerLib::compute; compute(0); } int main() { - compute(0); + f(); return 0; } diff --git a/ch18/ex18.1.2.3.cpp b/ch18/ex18.1.2.3.cpp index e236e52b..b181dcf0 100644 --- a/ch18/ex18.1.2.3.cpp +++ b/ch18/ex18.1.2.3.cpp @@ -89,3 +89,5 @@ int main() */ return 0; } + + diff --git a/ch18/ex18.15.16.17.cpp b/ch18/ex18.15.16.17.cpp index 2182cf1a..194e0048 100644 --- a/ch18/ex18.15.16.17.cpp +++ b/ch18/ex18.15.16.17.cpp @@ -164,6 +164,7 @@ namespace Test2 // using directive for namespace Exercise is located at the // location labeled position 2. + namespace Test3 { namespace Exercise @@ -219,4 +220,5 @@ int main() cout << endl; return 0; -} +} +