KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
#include <stdio.h> #include <stdlib.h> #include <string.h> char *method1(void) { static char a[4]; scanf("%s\n", a); return a; } int main(void) { char *h = method1(); printf("%s\n", h); return 0; } When I run the code above, the prompt is asking me twice for input (I only use scanf once in the code). Why is that? (I entered 'jo'; it asked for more input, so I entered 'jo' again. Then it only printed out 'jo' once.)
Tags (comma-separated)
Save Edits
Cancel