Od pewnego czasu mam pewien problem, bo visual studio pokazuje mi błąd gdy użyje funkcji strcpy() (włączyłem bibliotekę cstring). Na codeblocksie nie mam żadnych problemów. Poniżej wklejam przykładowy program. Może ktoś wie czemu tak się dzieje?
#include <iostream>
#include <cstring>
using namespace std;
struct stringy
{
char* str;
int ct;
};
void set(stringy&, char*);
void show(const stringy, int = 1);
void show(char*, int = 1);
int main()
{
stringy beany;
char testing[] = "Rzeczywistosc to juz nie to, co kiedys.";
set(beany, testing);
show(beany);
show(beany, 2);
testing[0] = 'D';
testing[1] = 'u';
show(testing);
show(testing, 3);
show("Gotowe!");
return 0;
}
void set(stringy& x, char* napis)
{
int length = strlen(napis)
char* pf = new char[length+1];
pf = x.str;
strcpy(pf, napis);
x.ct = strlen(pf);
}
void show(const stringy x, int n)
{
while (n > 0)
{
cout << " 1) Napis: " << x.str;
n--;
}
cout << endl << endl;
}
void show(char* word, int n)
{
while (n > 0)
{
cout << " 2) Napis: " << word;
n--;
}
cout << endl << endl;
}