| | |
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: 318 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C
#include * .net append array arrays bash binarysearch changingto char character cm command copyanyfile creafecopyofanytypeoffileinc createprocess() database directory dynamic execv feet fgets file floatingpointvalidation fork framework function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework ide include initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue mysql oddnumber odf openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi





