Help me with a string

Oct 17, 2015 at 4:24pm
Hello, help with errer of the code:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#include <string>
#include <string.h>

using namespace std;

int main()
{
	printf("Digite qualquer coisa: ");
	char search[256];
	scanf("%s", search);

	string s("http://www.google.com.br/search?q=");
	s.append(search);
	memset(search, 0, 256);

	s._Copy_s(search, 256, 256, 0);
	ShellExecute(NULL, "open", search, "", NULL, SW_SHOWNORMAL);
	return 0;
}

Oct 17, 2015 at 5:00pm
closed account (E0p9LyTq)
Ozzy69 wrote:
Hello, help with errer of the code:

Are the errors run time or compile time errors?

Please post the errors you are getting, if you can.

The more information you provide makes it easier to assist you.
Oct 17, 2015 at 5:03pm
This error:

"C:\Users\Rrodr\Desktop\bagaça.cpp|20|error: 'std::string' has no member named '_Copy_s'|"

line 20
Oct 17, 2015 at 5:58pm
Well yeah, it doesn't.

Here's the reference page for std::string and as you can see the is no _Copy_s function listed there.
http://www.cplusplus.com/reference/string/string/?kw=string

Not clear what you're trying to do with that statement, so can't suggest alternatives.



Oct 17, 2015 at 8:16pm
closed account (E0p9LyTq)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>
#include <windows.h>

int main()
{
   std::cout << "Digite qualquer coisa: ";
   std::string search;
   std::getline(std::cin, search);

   search = "http://www.google.com.br/search?q=" + search;

   ShellExecute(NULL, "open", search.c_str(), "", NULL, SW_SHOWNORMAL);

   return 0;
}


I don't ever recommend mixing C and C++ strings and functions. It can make debugging a nightmare.

The Windows API is already a nightmare. ;)
Oct 17, 2015 at 8:18pm
@Ozzy69 like FurryGuy said dont add string.h and string.
because you use append then use string header.
Oct 17, 2015 at 10:31pm
thanks!!!!
Topic archived. No new replies allowed.