Help me with a string

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;
}

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.
This error:

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

line 20
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.



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. ;)
@Ozzy69 like FurryGuy said dont add string.h and string.
because you use append then use string header.
thanks!!!!
Topic archived. No new replies allowed.