Question: The following code keeps giving me errors can anyone help edit it for me please i cant figure it out: this is the errors it
The following code keeps giving me errors can anyone help edit it for me please i cant figure it out:
this is the errors it gives me: -|437|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
-ld.exe||cannot open output file bin\Debug\c.exe Permission denied|
-||error: ld returned 1 exit status|
#include #include #include #include #include using namespace std;
struct FIELDS { string name; string value; };
const int cnt = 4;
// Prototypes void parse(string, FIELDS []); string param(string, FIELDS [], int);
//main begins int main() { FIELDS name_value_pairs [cnt];
string qs(getenv("QUERY_STRING")); //string qs("first=fred&last=flint&color=red"); cout << "Content-type:text/html "; cout << "debug with qs: " << qs << "
" << endl;
parse(qs, name_value_pairs); string first = param("first", name_value_pairs, cnt); string last = param("last", name_value_pairs, cnt); string color = param("color", name_value_pairs, cnt); string tcolor = param("tcolor", name_value_pairs, cnt); //HTML cout<<"Content-type:text/html "; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; }
if (color=="blue") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="orange") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="red") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="yellow") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="green") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="purple") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="black") { cout<<"
"; if (tcolor=="blue") { cout<<""; } else if (tcolor=="orange") { cout<<""; } else if (tcolor=="red") { cout<<""; } else if (tcolor=="yellow") { cout<<""; } else if (tcolor=="green") { cout<<""; } else if (tcolor=="purple") { cout<<""; } else if (tcolor=="black") { cout<<""; } else if (tcolor=="gray") { cout<<""; } else { return 0; } } else if (color=="gray") { cout<<"
"<<"Welcome"<<"
"; cout<<"
Hi "<"; cout<<"
How are you doing today?
"; cout<<"
Since you chose "<"; cout<<"
Since you chose "<";
if (color==tcolor) { cout<<"
"; cout<<""; cout<<"
Sorry, your background and font were the same color, so nothing was displayed. Please try again.
"; }
cout<<""< return 0; }
void parse (string qs, FIELDS f_name_value_pairs []) { string name, value; int start_pos = 0, pos; int counter =0; for (counter=0; counter { pos = qs.find("=", start_pos); name = qs.substr(start_pos, pos - start_pos); cout << "name: " << name << " " << endl; start_pos = pos + 1; pos = qs.find("&", start_pos); if (pos == string::npos) { pos = qs.length(); } value = qs.substr(start_pos, pos - start_pos); cout << "value: " << value << " " << endl; start_pos = pos + 1; f_name_value_pairs[counter].name = name; f_name_value_pairs[counter].value = value; } }
string param(string lookUp, FIELDS f_name_value_pairs[], int f_cnt) { int i; if (lookUp=="first") { i=f_cnt-4; return f_name_value_pairs[i].value; } else if (lookUp=="last") { i=f_cnt-3; return f_name_value_pairs[i].value; } else if (lookUp=="color") { i=f_cnt-2; return f_name_value_pairs[i].value; } else if (lookUp=="tcolor") { i=f_cnt-1; return f_name_value_pairs[i].value; } else { return " "; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
