| | |
How to buffer output?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 23
Reputation:
Solved Threads: 0
How to:
1. Buffer output ?
2. Get its size ?
3. Print the buffer ?
1. Buffer output ?
2. Get its size ?
3. Print the buffer ?
C Syntax (Toggle Plain Text)
#include <stdio.h> int main(void) { printf("Tons of printf lines\n"); // 1. Somehow buffer the output up until this point printf("The size of the buffer is: %i\n", SIZEOFBUFFER); // 2. Get and print the size of the buffer. printf("Here is the output:\n\n%s", BUFFER); // 3. Print the buffer. return 0; }
•
•
Join Date: Oct 2009
Posts: 27
Reputation:
Solved Threads: 2
0
#2 Oct 29th, 2009
•
•
•
•
How to:
1. Buffer output ?
2. Get its size ?
3. Print the buffer ?
C Syntax (Toggle Plain Text)
#include <stdio.h> int main(void) { printf("Tons of printf lines\n"); // 1. Somehow buffer the output up until this point printf("The size of the buffer is: %i\n", SIZEOFBUFFER); // 2. Get and print the size of the buffer. printf("Here is the output:\n\n%s", BUFFER); // 3. Print the buffer. return 0; }
What is SIZEOFBUFFER and BUFFER in your code and can you explain clearly what you want
0
#3 Oct 29th, 2009
•
•
•
•
How to:
1. Buffer output ?
2. Get its size ?
3. Print the buffer ?
C Syntax (Toggle Plain Text)
#include <stdio.h> int main(void) { printf("Tons of printf lines\n"); // 1. Somehow buffer the output up until this point printf("The size of the buffer is: %i\n", SIZEOFBUFFER); // 2. Get and print the size of the buffer. printf("Here is the output:\n\n%s", BUFFER); // 3. Print the buffer. return 0; }
C Syntax (Toggle Plain Text)
#define MAX_BUFFER 1000 char BUFFER[MAX_BUFFER]; BUFFER[0] = '\0'; strcat(BUFFER, toPrint);/*toPrint contains whatever u wanted to print*/ /*but check for the buffer content size because if it exceed MAX_BUFFER u wil get seg fault*/ /*do it for every printf("%s", toPrint)*/ printf("The size of the buffer is: %i\n", strlen(BUFFER)); // 2. Get and print the size of the buffer. printf("Here is the output:\n\n%s", BUFFER); // 3. Print the buffer.
Last edited by dkalita; Oct 29th, 2009 at 4:06 am.
•
•
Join Date: Oct 2009
Posts: 23
Reputation:
Solved Threads: 0
0
#4 Oct 29th, 2009
•
•
•
•
may be something like
C Syntax (Toggle Plain Text)
#define MAX_BUFFER 1000 char BUFFER[MAX_BUFFER]; BUFFER[0] = '\0'; strcat(BUFFER, toPrint);/*toPrint contains whatever u wanted to print*/ /*but check for the buffer content size because if it exceed MAX_BUFFER u wil get seg fault*/ /*do it for every printf("%s", toPrint)*/ printf("The size of the buffer is: %i\n", strlen(BUFFER)); // 2. Get and print the size of the buffer. printf("Here is the output:\n\n%s", BUFFER); // 3. Print the buffer.
![]() |
Similar Threads
- PHP Warning: Cannot modify header information - headers already sent by (output ..... (PHP)
- How do I write code for PAC MAN! (C++)
- Writing the output of subprocess to a file (Python)
- Hexadecimal and Linear feed shift register :( (C)
- want info. abut flush (C++)
- Cannot modify header information.Headers already sent (PHP)
- Accepting decimal value as hex value (C)
- command line arguments help (C)
- stopper (C)
- XTEA Encryption (C++)
Other Threads in the C Forum
- Previous Thread: problem regarding trees in data structures using c
- Next Thread: Compile program for both 32 and 64 bit?
Views: 319 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory drawing dynamic executable feet fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide infiniteloop initialization interest intmain() kilometer lazy license linked linkedlist linux linuxsegmentationfault list match matrix meter microsoft multi mysql oddnumber odf open openwebfoundation pattern pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition scheduling segmentationfault send shape single socketprogramming spoonfeeding stack standard strchr string strings structures student suggestions system test testautomation unix urboc user visualstudio voidmain() win32 win32api windows.h





