I have some C++ code that is right programatically and will give the right outpu
ID: 3886665 • Letter: I
Question
I have some C++ code that is right programatically and will give the right output, but when I run it in linux and use the script my teacher wants the output file is empty after executing it. Below is what I am getting. I am running Linux and using a script my teacher made. I can post all my actual code if that is needed to helo me out.
COMPILING hwprog2
rm: cannot remove '*.o': No such file or directory
rm: cannot remove 'Aprog': No such file or directory
g++ -O3 -Wall -std=c++11 -c main.cc
main.cc: In function ‘void calculateDistance(std::vector<double>&, std::vector<double>&)’:
main.cc:96:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int a=0;a<myvector.size();a++)//for loop starts from first element of vect
^
main.cc:98:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int b=a+1;b<myvector.size();b++)//this for loop starts from next element
^
main.cc:100:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int c=b+1;c<myvector.size();c++)//this for loop starts from next element
^
main.cc: In function ‘int main()’:
main.cc:129:19: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
system("pause");
^
g++ -O3 -Wall -std=c++11 -c ../../Utilities/scanner.cc
g++ -O3 -Wall -std=c++11 -c ../../Utilities/scanline.cc
g++ -O3 -Wall -std=c++11 -c ../../Utilities/utils.cc
g++ -O3 -Wall -std=c++11 -o Aprog main.o scanner.o scanline.o utils.o
Return from 'testdirectory' directory
COMPILING COMPLETE
Explanation / Answer
Please find my answer:
Your teacher,s script is trying to remove '*.o' and 'Aprog' files, if there is no file then
this error will be coming:
rm: cannot remove '*.o': No such file or directory
rm: cannot remove 'Aprog': No such file or directory
To fix this:
for(int a=0;a<myvector.size();a++)//for loop starts from first element of vect
^
Ans: for(unsigned int a=0;a<myvector.size();a++)
To fix this:
for(int b=a+1;b<myvector.size();b++)//this for loop starts from next element
Ans: for(unsigned int b=a+1;b<myvector.size();b++)
To fix this:
for(int c=b+1;c<myvector.size();c++)//this for loop starts from next element
Ans: for(unsigned int c=b+1;c<myvector.size();c++)