Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

scanf Output not showing of C language in kali terminal

I am currently doing C programming in the terminal of nano text editor in kali linux 2020.x.
15 minutes ago, I wrote a code which is not working finely. I am mentioning that code.

#include<stdio.h>
int main(){
  int num;
  scanf("%d",&num);
  printf("number is %d",num);
  return 0;
}

I ran it. all things were ok, it compiled also, but when I am trying to enter value and press enter key, the output is blank/no output.

question from:https://stackoverflow.com/questions/65879685/scanf-output-not-showing-of-c-language-in-kali-terminal

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't know if you have an answer yet, but I gave your question a shot and made this:

int main()
{

    int m_iValue = 0;
    
    scanf( "%i", &m_iValue );

    {
              char m_szBuffer[128]; // Note: We got a BIG buffer boy!
        sprintf( m_szBuffer, "Value: %i 
", m_iValue );

        printf( m_szBuffer );
    }

    return 0;

}

It works perfectly fine; hope it helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...