Results 1 to 3 of 3

Thread: Input

  1. #1
    Guest

    Post

    Ok, im using Borlands Turbo C and im new. What kind of line do i put in to let the keyboard input a string?

  2. #2
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207

    Post C Strings

    I sent you a mail attatchment with a small program in it.

    Jeremy

  3. #3
    Guest
    You can't get a string,persay,from the command line.
    What you can get is a character array, so,
    do the following

    char buffer[256]; //or however long you expect input to be
    cout << "Enter something..";
    cin >> buffer;
    cout << buffer;
    cout.flush();
    /*
    do whatever else you need to do
    */

    As far as the string is concerned you can #include<cstring.h>
    and then use
    string buffer;
    and use something like buffer.length() and buffer.get_at(3)
    and so on.
    If you use the string object you can't do
    cout << buffer;
    or cin >> buffer;

    unless you convert the buffer variable to a cstring,
    check your documentation for details.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width