I will post the two versions of my code, the first program throws compile time errors, the second compiles and executes successfully. I would like to know if my compiler is complaining because it is just terrible, or if I'm actually violating the syntax of c++11 standard.
//C++ Chapter 4 Drills
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
inline void winWedge(){char c;std::cin>>c;}
int main(){
//This is the beginning of the error
std::cout<<"Every time this program loops put in 2 numbers and it will print.\n
When you want it to stop, put in the symbol | ";
//This is the end of the error
std::string word1="a";
std::string word2="b";
while(word1!="|"&&word2!="|"){
std::cin>>word1>>word2;
std::cout<<"\n\n"<<word1<<" "<<word2<<"\n\n";
}
//winWedge();
return 0;
}
---------------------------------------------end of first program---------------
//C++ Chapter 4 Drills
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
inline void winWedge(){char c;std::cin>>c;}
int main(){
std::cout<<"Every time this program loops put in 2 numbers and it will print.\n"
<<"When you want it to stop, put in the sybol | ";
std::string word1="a";
std::string word2="b";
while(word1!="|"&&word2!="|"){
std::cin>>word1>>word2;
std::cout<<"\n\n"<<word1<<" "<<word2<<"\n\n";
}
//winWedge();
return 0;
}
Obviously the second program compiles and runs, but it makes me inexplicably furious that my compiler is telling me there is an error when I don't believe there is, and it is refusing to compile the code. This is not python, so why is the whitespace causing this problem? is it the invisible 'return' character?
Everyone knows the adage about blaming your tools, so if this is all I'm doing please call me on it, I'm trying to learn so criticism is welcome as is any insight you can offer.
Aucun commentaire:
Enregistrer un commentaire