bonjour,
je suis un debutant, j'utilise Dev-c++ pour programmer en C. l� j'assaie de creer des fonctions dans un fichier puis de les utiliser dans un programme.
Voila ce que j'ai fait et qui ne marche pas:
1)j'ai creer un fichier toto.c et toto.h dans un dossier titi.
a) toto.c contient:
b)toto.h contient
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include<stdlib.h> char *concatener(char *ch1,char *ch2) { char *ch=(char*)malloc(100*sizeof(char)); int i=0,j=0; while(ch1[i]) { ch[i]=ch1[i]; i++; } while(ch2[j]) { ch[j+i]=ch2[j]; j++; } ch[i+j]='\0'; return ch; }
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7 #ifndef H_STRING #define H_STRING char *concatener(char *,char *); #endif
et quand j'invoque concatener dans un main comme:
�a marche pas
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11 #include<stdio.h> #include<stdlib.h> #include"c:\titi\toto.h" main() { char *t1,*t2; gets(t1); gets(t2); puts(concatener(t1,t2)); system("pause"); }
De l'aide
Partager