Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » printf() is not appearing.(printf() is not appearing on the console of CPP version of eclipse. After giving inputs all printf() statements appears at once.)
printf() is not appearing. [message #1770733] Wed, 16 August 2017 15:26 Go to next message
ANKUR PRAMANIK is currently offline ANKUR PRAMANIKFriend
Messages: 1
Registered: August 2017
Junior Member
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
void sort(int*, int);
int main() {
int i, *arr, n;
printf("\nEnter the number of values: ");
scanf("%d", &n);
arr = (int*) malloc(n * sizeof(int));
for (i = 0; i < n; i++) {
printf("\nEnter value: ");
scanf("%d", (arr + i));
}
printf("\nThe sorted list is: ");
sort(arr, n);
return 0;
}
void sort(int* arr, int n) {
int temp, i, j;
for (i = 0; i < n - 1; i++) {
for (j = 0; j < n - i - 1; j++) {
if (*(arr + j) > *(arr + (j + 1))) {
temp = *(arr + j);
*(arr + j) = *(arr + j + 1);
*(arr + j + 1) = temp;
}
}
}
for (int p = 0; p < n; p++) {
printf("%d\t", *(arr + p));
}
}
  • Attachment: Capture.JPG
    (Size: 30.20KB, Downloaded 215 times)
Re: printf() is not appearing. [message #1770769 is a reply to message #1770733] Thu, 17 August 2017 02:18 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
stdout is buffered.
You need to do one of
1) fflush(stdout) when you want the output (say, after a prompt) http://www.cplusplus.com/reference/cstdio/fflush/
2) change the buffering scheme http://www.cplusplus.com/reference/cstdio/setvbuf/



[Updated on: Thu, 17 August 2017 02:26]

Report message to a moderator

Previous Topic:Copying a folder from any location to Workspace (CDT)
Next Topic:Problems with Oxygen and C++11
Goto Forum:
  


Current Time: Thu Apr 25 20:13:09 GMT 2024

Powered by FUDForum. Page generated in 0.03332 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top