Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
594 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 Answer

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...