Thread: Manipulating and Accessing Buffers in C

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2021
    Posts
    4

    Question Manipulating and Accessing Buffers in C

    Consider, for instance, a simple C program as follows:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main()
    {
        char arr[20];
        gets(arr);
        exit(EXIT_SUCCESS);
    }
    Ignore the deployment of scanf() for a moment. Nevertheless, the user enters the string and presses enter, which corresponds to the ASCII newline character (\n). Now, pray explain where the user-input gets stored initially. Is the string initially stored in a buffer and then passed to the character array "arr"? If so, it is passes serially or passed at once? If the aforementioned isn't applicable, is the string directly copied into the character array serially?

    Moreover, on a tangential note, what precisely is a buffer in C? Where can I find resources apropos the functionality, description, and management of this specific buffer? Countless instances of my programs that invoke the scanf() and fgets() functions malfunction owing to a lingering newline character in the buffer. What does this imply? I was given to understand, much to my chagrin, that the program directly stores the data in the character array. Is this not the case? How does one manipulate and access the buffer?
    Last edited by Salem; 10-09-2021 at 07:35 AM. Reason: Font size abuse!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. You know... I still don't get buffers.
    By SlyMaelstrom in forum C++ Programming
    Replies: 13
    Last Post: 06-15-2006, 06:47 AM
  2. Copying buffers?
    By fireonyx in forum C Programming
    Replies: 7
    Last Post: 03-08-2006, 10:20 AM
  3. Copy to Buffers
    By egomaster69 in forum C Programming
    Replies: 3
    Last Post: 12-05-2004, 06:50 PM
  4. copying buffers
    By Nor in forum C++ Programming
    Replies: 2
    Last Post: 07-14-2003, 06:54 AM

Tags for this Thread