0
Hello, I’m having doubts about how to pass determined by reference.
Follow the code below:
#include <stdio.h>
#include <string.h>
mostra_frase(char *frase){
printf("\nFrase digitada %s\n", frase);
}
void mostra_numero (int *numero){
printf("Numero digitado %i", *numero);
}
int main(){
char frase[100];
int numero;
printf("Digite uma frase\n");
gets(frase);
printf("Digite um numero\n");
scanf("%i", &numero);
mostra_frase(frase);
mostra_numero(&numero);
}
My question is: Why in the passage by reference of the phrase using gets do not need to pass the memory &address and in passing a number yes ?
Because the name of an array actually refers to the address of the first element of that array.
– anonimo
The pointer in
mostra_numero()
is completely unnecessary.gets(0
should not be used anymore.– Maniero