Thanks for your suggestion, but i need to have boost libraries for that and i wouldn't like to have any dependencies.
Type: Posts; User: radnik
Thanks for your suggestion, but i need to have boost libraries for that and i wouldn't like to have any dependencies.
You are right. What a stupid mistake. I should have used argv[2]. Thanks for your help MacGyver.
First of all i've read the reference, and second if that is so why does this come up with a segmentation fault?:
double speed;
speed=strtod(argv[3], NULL);
or even this:
strtod takes a string while argv[] is a pointer. How can i copy the value of argv[3] to some sort of string to pass it to strtod?
I have class goto(speed), that takes double as an argument. What i would like to do is to allow user to set the speed when running the program from command line. The start of program would look like:...
Ok i have problem again right at the start. I don't know how to pass vector with index (vector[x]) as function argument. I did this:
double distance (Paths path[i]) {
double dist, tmp;
for...
Ok, thanks. I'll try that later today and post you on how it went.
You can see the formula i need to use on this link:
http://en.wikipedia.org/wiki/Euclidean_metric.
I thought to calculate distance for all paths and store these values in vector of doubles. Then...
Dwks thank you very much, this is great. I have only one more thing to do. Now i must calculate Euclidean distance for all paths in trajectories vector. Sort them and find the shortest path so i can...
If i'm right the repeating of numbers occurs because i never clear my pairs vector so those old coordinates remain in the vector. How can i solve this? I've tried this:
while (stmp >> x >> y) {...
You are right laserlight. Sorry for the Croatian language. I will post English version now. I don't know what you mean by formatting of code because all of the "layout" was done by my editor i didn't...
Anyone?? :(
Guys i'm really desperate here. I'm obviously doing something wrong and i don't know what. I post the code and you compile it and look at the output. I have no clue what is the problem and i'm sure...
I know that, but when i read two values x and y how can i do bush back. How can i know that it will read the x value in vetor.x and y in vector.y?So when i read the values from file like this:
...
Thanks, that helped a lot. What do you suggest me to do on writing numbers of one path in vector Path. Since i don't set it's size (for logical reasons) i can't use something like:
while (stmp...
I'm stuck again. Now when i do something like:
string tmp;
getline(dat, tmp);
stringstream stmp(tmp);
i have stringstream stmp with one line of numbers from txt file. But how do i read...
Oh, i see. Thank you guys very much.
Can someone please help me with this stringstream. Just give me a good link if you know it or explain it to me how to parse integers from string with it please.
Ok, thank you. Where can i read about usage of getline and stringstream because i don't have any books on c++?
Here's the file. This is just one example. The file can have unknown number of lines (paths) and unknown number of point per path (where first number is x, second y, third x and so on):
12 14 15...
Thanks matsp. In the first solution i didn't use the class approach but typedefs. The compiling went well but when i run the program with correct file path to open i get a segmentation fault. Can you...
WHre in the code should i put the operator overloading main() or...? Because i got this error on compiling:
eg_decomposition.cpp:34: error: 'std::ostream& Koord::operator<<(std::ostream&, Koord)'...
Ok you lost me completely there. I don't know anything about operator overloading. How can i do that? (this c++ is complicated as hell). I've started something on the class approach so i will post my...
The code is almost the same as the one before:
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <vector>
using namespace std;
class Koord { //varijabla vrijednosti...
I figured out that one object represents on complete path, but i don't understand how should i implement collection of object (full collection of complete paths) since i don't know the number of...