+ 1

why does this short program keep telling me that strings a-j are not declared?

#include <iostream> #include <string> using namespace std; int main() { string a,b,c,d,e,f,g,h,i,j; int choice1; int choice2; int p1points; int p2points; a=threadwire; b=hammer; c=knife; d=acid; e=pistol; f=rifle; g=grenade; h=bazooka; i=rpg; j=tank;

11th Sep 2016, 8:25 PM
Cody Arthur
Cody Arthur - avatar
4 odpowiedzi
+ 5
you forgot to add your quotes to the declaration of string. for example f="rifle" instead of f=rifle. the latter is saying set variable f equal to variable rifle which doesn't exist
11th Sep 2016, 8:33 PM
destro
+ 2
thanks destro. it worked. really helpful
12th Sep 2016, 11:40 AM
Cody Arthur
Cody Arthur - avatar
+ 2
we should declare it like a="jac"; and not a=jac because jac is not a variable. if it is str a="abc" ; str b="a"; then a is abc and b a but if it is b=a; b is abc
4th Nov 2016, 6:57 AM
Sandeep Chatterjee
- 2
how r u guys ??
12th Sep 2016, 12:55 AM
Aswin Michael