Nevermind, i didn't want "&" i wanted << so i could join different strings.
Look a few posts below for the fixed code
Printable View
Nevermind, i didn't want "&" i wanted << so i could join different strings.
Look a few posts below for the fixed code
... Ctrl and 7, I'm guessing. You serious?!
Shift*Quote:
Originally posted by Barguast
... Ctrl and 7, I'm guessing. You serious?!
What do you mean, do an '&' sign?
If you mean the & (logical and) operator, here's what it does.
Syntax:
answer = num1 & num2
It ANDs the bits in num1 and num2 together. AND means if a bit in num1 is equal to 1 and the same bit in num2 is equal to 1, the output is 1. If not, the output is 0.
For example:
7 & 3 = 3
129 & 7 = 1
129 & 128 = 128
Look at the bits and you'll get it:
111 & 011 = 011
10000001 & 00000111 = 00000001
10000001 & 10000000 = 10000000
you think i am that dumb? geeze . . . i mean i though there might be a friggin trick to that operator. Do i have to include a header or c file to use it?
Code:#include <iostream.h>
int Main()
{
char First_Name[16];
char Last_Name[16];
int Grade_Level;
int Age;
cout<<"What is your First Name?";
cin>>First_Name;
cout<<"What is your Last Name?";
cin>>Last_Name;
cout<<"What grade are you in?";
cin>>Grade_Level;
cout<<"How old are you?";
cin>>Age;
cout<<"Name: " & First_Name & Last_Name & " Grade: " & Grade_Level & " Age: " & Age endl;
return 0;
}
In that context, replace it with <<.
& is used for string concatenation in VB only. It's completely different in C++.
In C strings (char arrays) you may use strcat to concatenate strings. In C++ strings (std::string) you can use the + operator. In character streams (strstream, or ostream, such as cout) you should use <<.
Code:cout<<"Name: " << First_Name << Last_Name << " Grade: " << Grade_Level << " Age: " << Age << endl;
Ok, i fixed my code:
[code]
#include <iostream.h>
int main()
{
char First_Name[16]
char Last_Name[16]
int Age
cout<<"Please enter your first name.";
cin>>First_Name;
cout<<"Please enter your last name.";
cin>>Last_Name
cout<<"Please enter your age."
cin>>Age
cout<<"Name :" << First_Name << " " <<Last_Name << "Age: " << Age;
return 0;
}