Probiere Überladen, Fehler!

desaster0505

Erfahrenes Mitglied
Hallo!

Probiere hier ein kleines Programm unter Linux

C++:
#include <iostream>
#include <cstring>
using namespace std;

int n;
char string1[20], string2[20];

void stringCopy(char *ziel, char *quelle){
	strcpy(ziel, quelle);
}

void stringCopy(char *ziel, char *quelle, n){
	strncpy(ziel, quelle, n);
}


int main(){

stringCopy(string1, "Hallo Welt");
stringCopy(string2, string1, 5);

cout << string1 << endl;
cout << string2;


return 0;
}


Aber folgende Fehler erscheint beim compilieren mit g++ und ich weiss nicht wieso "n" kein Typ sein soll?!


»n« is not a type



Vielleicht könnt ihr mir helfen
 
Jup musser, würde auch nicht mit globalen Variblen arbeiten, gibt zuviele Probleme/Missverständnisse. So sollte es jedenfalls gehen, wies sich aber mit der globalen n beisst, frag mich ent^^
C++:
void stringCopy(char *ziel, char *quelle, int n)
 
Zurück