Hi I am new to structures and am practicing this code to add numbers from a command line argument to numbers given using structures and functions. If anyone can help I would appreciate it thanks. Here is my code im almost done at it compiles but i get a wrong output, my output say for 2 numbers entered in cmd line arguments(parameters) are 5 and 6. when added to 3 and 4, my output should be 10.
Code:#include <iostream> #include <stdlib.h> using namespace std; struct complex { double real, imag, real1, imag1; }; void value(double *pt1, double &pt2) { complex num; *pt1 = num.real + num.real1; pt2 = num.imag + num.imag1; } int main(int argc, char *argv[]) { complex number; double val1; double val2; number.real=3; number.imag=4; number.real1 = atof(argv[1]); number.imag1= atof(argv[2]); value(&val1, val2); cout << val1 << endl; cout << val2 << endl; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks



</edit>