Fri Aug 22 04:38:54 CEST 2008

cpp.png C++ for Runaways

Because of neuroinformatics I try to write a little neural network in C++. I am not a big C++ expert so I had to review some things.

If you would like to stream a file C++-like with std::ifstream file(filepath); and you put it into a function which needs the filepath as an argument you need to use char* filepath instead of std::string filepath. That surprised me much because char* is bad C++ style somehow.

Another problem was the output of real numbers. Firstly I used std::cout to print these using the float type. But it shows me only six decimal places.
Then I tried the C style with printf. The solution was, to use double (it is really enough for our purposes) and printf("%.10E\n", input);.
That surprised me, too, because I used a C element just another time instead of C++.

After it I've done a really bad mistake. I used the << operator together with an ifstream variable. But it is not defined with that. I had to use ofstream of course.

Another thing was that you cannot declare a variable y1 and y2 if you use math.h, because they were already declared there. Interesting. I didn't know that...

Posted by Sebastian Wieseler | Permalink | Categories: projects/programming |

Sat Aug 16 15:39:54 CEST 2008


Believing: Who believes in me? Who trusts in me? Anybody?

Sometimes I don't know where I should go - what to do next. Sometimes I feel alone. Why cannot anybody show me the right way?

Posted by Sebastian Wieseler | Permalink | Categories: personal notes |