Is cin for only numbers??

This is a discussion on Is cin for only numbers?? within the C++ Programming forums, part of the General Programming Boards category; That is because name[10] does not exist, the array only consists of elements 0-9. Try this... Code: #include <iostream> using ...

  1. #16
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    That is because name[10] does not exist, the array only consists of elements 0-9. Try this...

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    	char name[10];
    	cin.getline(name, 11);
    	cout<<name;
    	cout << name[9];
    
    	return 0;
    }
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  2. #17
    Back after 2 years Panopticon's Avatar
    Join Date
    Dec 2002
    Posts
    262
    dang... i cant believe i forgot something so fundamental.
    I guess i shouldnt rush things, no matter how simple they appear to be...
    Thanks
    I AM WINNER!!!1!111oneoneomne

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM
  2. input with cin....
    By MainFrame in forum C++ Programming
    Replies: 3
    Last Post: 03-19-2004, 05:10 PM
  3. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 10:15 AM
  4. Line Numbers in VI and/or Visual C++ :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 02-10-2002, 09:54 PM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 05:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21