Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void giocatori(char *gioc1,char *gioc2){
- char c;
- char *tmp;
- int dim=0;
- printf("Inserisci il tuo nickname Giocatore 1 \n");
- do{
- c=getchar();
- if(c!='\n') {
- tmp=malloc(sizeof(char)*dim);
- strcpy(tmp,gioc1);
- dim++;
- gioc1=malloc(sizeof(char)*dim);
- strcpy(gioc1,tmp);
- gioc1[dim-1]=c;
- free(tmp);
- }
- }while(c!='\n');
- gioc1[dim]='\0';
- printf("%s",gioc1);
- }
- int main() {
- char giocatore1[1];
- char *giocatore2;
- giocatori(giocatore1,giocatore2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement