• Welcome to Jose's Read Only Forum 2023.
 

ProgEx23 - Use Of gets (get string). Its Like PowerBASIC Line Input

Started by Frederick J. Harris, November 09, 2009, 01:17:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frederick J. Harris


/*
  ProgEx22   --    (program should run as C or C++)
 
  Simple program shows how to read a line of keyboard input into an 256 byte
  buffer.  Just enter a line of text and press [ENTER].  Its equivalent to the
  following PowerBASIC Console program...
 
  #Compile Exe
  #Dim All

  Function PBMain() As Long
    Local szBuffer As Asciiz*256
 
    Line Input szBuffer
    Print szBuffer
    Waitkey$
   
    PBMain=0
  End Function
 
  You need to be careful to make the buffer into which you want the text line
  read to be big enough.
*/

#include <stdio.h>
#define MY_SIZE 256

int main(void)
{
char szBuffer[MY_SIZE];
 
gets(szBuffer);
puts(szBuffer);
getchar();

return 0;                     
}

/*  --Output--
==============
Some Line Of Text I Entered!
*/