Error C3867

I tried many methods,i am lost with it.i need your help

1
2
source.cpp(28): error C3867: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str': function call missing argument list; '&std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str' create a pointer to member
source.cpp(30): error C3867: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str': function call missing argument list; '&std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str' create a pointer to member

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>

using namespace std;

int main() //recompose vocab
{
	int n = rand() % 3 + 1;

	string vocab = "vocab";

	switch (n)
	{
	case 1: vocab = "apple"; break;
	case 2: vocab = "banana"; break;
	case 3: vocab = "carrot"; break;

	}

	int ran = rand() % vocab.length();

	string partone = vocab.substr(0, ran);
	string parttwo = vocab.substr(ran);

	char part_1[20], part_2[20];
	strcpy(part_1, partone.c_str);

	strcpy(part_2, parttwo.c_str);


	cout << strrev(part_1) << strrev(part_2);

	return 0;

}
Lines 28 and 30.
c_str is a function, not a member variable. Call it as a function: partone.c_str()
why do you use strcpy() in this case? You can use reverse with string:

http://www.cplusplus.com/reference/algorithm/reverse/?kw=reverse

The error is that you forgot the ():
1
2
3
	strcpy(part_1, partone.c_str()); // Note ()

	strcpy(part_2, parttwo.c_str()); // Note () 
really? as my teacher told me that strrev is for char,
big thank to booradley60 and coder777
i try to use reverse then

i find reverse_iterator is suitable for me, thanks anyway
Last edited on
Topic archived. No new replies allowed.