+ 1
display variable using function
how to print my name using function in C program.. #inlcude<stdio.h> int variable(int); int main() { int x=jordan; printf("%d",variable); }
10 Réponses
+ 2
Jordan is a string, so it has to be in ""
+ 1
#include <stdio.h>
int main(){
char name[]="Jordan";
printf("name is %s.\n",name);
return 0; }
+ 1
#include <stdio.h>
/* function return type is void and it doesn't have parameters*/
void self() {
printf("Hi\n");
printf("Jordan\n");
printf("that's what you want ?");
/* There is no return statement inside this function, since its * return type is void */
}
int main() {
/*calling function*/
self();
return 0; }
+ 1
Thanks
+ 1
Donna
gets() reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces with a null byte (aq\0aq). No check for buffer overrun is performed.
fgets() reads in at most one less than sizecharacters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte (aq\0aq) is stored after the last character in the buffer.
so I prefer to use fgets it's more safe
and on second note it's a user generated lessons so may be he is unknown of that
0
but where is function brother...
im not talking about arrray
0
Donna btw for printing only name it's good but it consider as a bad practice to use gets()
The gets() function in C is inherentlyunsafe. ... However, the programmer uses the function gets() which is inherently unsafe because it blindly copies all input from STDIN to the buffer without checking size. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.
0
int var = chars?
Printing out functions!
what has happened to humanity.😶