Skip to content

Commit

Permalink
Please enter the commit message for your changes. Lines starting
Browse files Browse the repository at this point in the history
  • Loading branch information
SC K authored and SC K committed Mar 19, 2017
1 parent 7115171 commit 5de68d6
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 38 deletions.
59 changes: 34 additions & 25 deletions ch17/17_37_38/17_37_38.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

int main () {
ifstream myfile ("test.txt");
char sink [250];

while(myfile.getline(sink,250,' '))
{
cout << sink << endl;
}
return 0;
//#include <iostream>
//#include <fstream>
//#include <iomanip>
//
//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";
}
2 changes: 2 additions & 0 deletions ch17/17_37_38/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ch17/ex17_28_29_30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <iostream>
#include <random>
#include<string>

// default version
unsigned random_gen();
Expand Down
2 changes: 1 addition & 1 deletion ch17/ex17_33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ch18/18_18 18_19.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions ch18/18_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<typeid(x).name()<<std::endl;
#include<iostream>

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;
}

Expand Down
2 changes: 2 additions & 0 deletions ch18/ex18.1.2.3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ int main()
*/
return 0;
}


4 changes: 3 additions & 1 deletion ch18/ex18.15.16.17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace Test2

// using directive for namespace Exercise is located at the
// location labeled position 2.

namespace Test3
{
namespace Exercise
Expand Down Expand Up @@ -219,4 +220,5 @@ int main()
cout << endl;

return 0;
}
}

0 comments on commit 5de68d6

Please sign in to comment.