Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6841947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:01:58+00:00 2026-05-27T00:01:58+00:00

Why is the output of the printf is not show when stepping out the

  • 0

Why is the output of the printf is not show when stepping out the line? But at some point it did print line 16.

c file:

#include<stdio.h>

void nextfunc(){
    int ctr;    
    for(ctr = 0; ctr<3; ctr++){
        printf("print ctr = %d",ctr);
    }
    printf("last print");
}
void main(){

    int x;
    printf("input x: ");
    scanf("%d",&x);
    printf("\nprint 2");
    printf("\nprint 3");
    nextfunc();
}

GDB:

    (gdb) break main
    Breakpoint 1 at 0x8048479: file file5.c, line 14.
    (gdb) break nextfunc
    Breakpoint 2 at 0x804843a: file file5.c, line 6.
    (gdb) run
    Starting program: /home/charmae/workspace/AVT/file5 

    Breakpoint 1, main () at file5.c:14
    14      printf("input x: ");
    (gdb) s
    15      scanf("%d",&x);
    (gdb) s
    input x: 4
    16      printf("\nprint 2");
    (gdb) s

    17      printf("\nprint 3");
    (gdb) s
    print 2
    18      nextfunc();
    (gdb) s

    Breakpoint 2, nextfunc () at file5.c:6
    6       for(ctr = 0; ctr<3; ctr++){
    (gdb) s
    7           printf("print ctr = %d",ctr);
    (gdb) s
    6       for(ctr = 0; ctr<3; ctr++){
    (gdb) s
    7           printf("print ctr = %d",ctr);
    (gdb) s
    6       for(ctr = 0; ctr<3; ctr++){
    (gdb) s
    7           printf("print ctr = %d",ctr);
    (gdb) s
    6       for(ctr = 0; ctr<3; ctr++){
    (gdb) s
    9       printf("last print");
    (gdb) s
    10  }
    (gdb) s
    main () at file5.c:19
    19  }
    (gdb) s
    0x0014a113 in __libc_start_main () from /lib/i386-linux-gnu/libc.so.6
    (gdb) s
    Single stepping until exit from function __libc_start_main,
    which has no line number information.
    print 3print ctr = 0print ctr = 1print ctr = 2last print[Inferior 1 (process 2578) exited with code 012]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:01:59+00:00Added an answer on May 27, 2026 at 12:01 am

    Output though stdout is buffered. That means it is saved in a temporary buffer either until the buffer is full, there is a newline being printed or the function fflush(stdout) is called. stdout is flushed automatically also when the program ends.

    The reason your output is printed “on the wrong place” in GDB is because of this buffering. you should either add newlines to the end of the printf format string, or explicitly call fflush.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include<stdio.h> int main() { printf(He %c llo,65); } Output: He A llo #include<stdio.h> int
I tried an example from this website: http://www.cs.cf.ac.uk/Dave/C/node24.html Sometimes, the output does not show
class classe (){ public: int key; static void *funct(void *context){ printf(Output: %d, , key);
is there a way to get with printf colored output? #!/usr/bin/perl use warnings; use
As everybody knows, you have limited precision when you use printf to output the
How can I output colored text using printf on both Mac OS X and
Is there a way to modify the printf in order to output string on
When I use printf/printf_s with two strings, I get the same output for both
In the following: printf(Example%s\n,NULL); printf(%s\n,NULL); I get the output as: Example(null) Segmentation Fault When
I don't understand the output of this program: int arr[]={1,7,4,2,5,8}; int x=(&(arr[arr[1]-arr[4]])-arr); printf(%d ,x);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.