0

I would like to know how can I return a string in c and then send it as a parameter to another funcion. For example, in those functions:

This is the function that returns a char *:

char * read(){
    char c[4];
    printf("Write the string:\n");
    scanf(" %[^\n]", c);
    return c;
}

And this one takes it as a parameter and prints it:

void printc(char *a){
    printf("%s", a);
}

I've tried doing:

printc(read()); 

But it doesn't work. What's the best way to do this?

eduardosufan
  • 1,441
  • 2
  • 23
  • 51
kalia
  • 219
  • 1
  • 13

0 Answers0