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