Hi ppl,
I've written a simple program with strings. this just recives the name and last name of a person, and then print it.
i had a few problems with this: at first, it didnt let me define a variable as "string", it gave this error:
C2679: binary '>>': no operator defined wich takes a right-hand operand of type 'class std::basic_string <char, struct std::char_traits <char>, class std::allocator <char> >'
and dont know what it is, so i had to change those variables to char.
another problem i had was with the
strcat (name, last_name);
. i should print the result of it at the end, but tried and didnt work (actually did, but gave as a result a number, so its the same as it didnt work)
what can i do with both problems??
tnks!!
gispe!!
#include "stdafx.h"
#include <iostream>
#include <string.h>
int main(int argc, char* argv[])
{
using namespace std;
char name [20], last_name [20];
cout << " Type the name: ";
cin >> name;
cout << "\n";
cout << " Type the last name: ";
cin >> last_name;
cout << "\n";
strcat (name, last_name);
cout << " The name you entered is: " << name << " " << last_name << "\n";
return 0;
}