[Gelöst] Pointer als Übergabeparameter
-
Nochmal Hallo zusammen,
Ich habe noch eine Frage zu VC++.net 2005:
In C übergebe ich oft Char* an eine Funktion und Fülle diesen dann mit Zeichen:
int fillup(char *buffer) { //mache irgendwas buffer = "1234"; return 0; } int main (int argc, char *argv) { char buffer[MAXLEN]; inr rc; //some code rc = fillup(&buffer); //some code }
Wie funktionier sowas mit System::String?
Das hier:int test(String ^test) { test = L"1234"; return 0; } int main(array<System::String ^> ^args) { String ^input; test(input); Console::WriteLine(input); Console::ReadKey(); return 0; }
tuts nicht...
Aber wie dann?
Danke euch schonmal.
Gruss,
Nils
-
int test(String %test)
-
Das haut nich hin:
int test(String %test) { test = L"1234"; return 0; } int main(array<System::String ^> ^args) { String ^input; test(input); Console::WriteLine(input); Console::ReadKey(); return 0; }
bringt:
.\test.cpp(7) : error C3699: '%' : cannot use this indirection on type 'System::String' .\test.cpp(9) : error C2582: 'operator =' function is unavailable in 'System::String' .\test.cpp(17) : error C2664: 'test' : cannot convert parameter 1 from 'System::String ^*' to 'System::String %'
???
-
Habs nichjt getestet aber so sollte es dann wirklich gehen:
int test(String^ %test)
-
Bingo.. Funktionert
Dankeschön