kinda new need help

This is a discussion on kinda new need help within the C++ Programming forums, part of the General Programming Boards category; Hey there im taking a intro course to c++ and we have a small assignment where we have the user ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    kinda new need help

    Hey there im taking a intro course to c++ and we have a small assignment where we have the user input a string like:
    He was 14 ten years ago. The next line should display just the numbers.
    14.
    Code:
    int main()
    {
    
    	char word[20];
    	int a;
    	cout<<"Enter a sentence with at least one number in it."<<endl;
    	cin.getline(word,20);
    	for(word[20])
    	{
    	if(!isdigit((unsigned char)word[20])>=0)
    	{
    	cout<<word<<endl;
    	}
    	}
    	system("PAUSE");
    
    }
    i also know i have all the appropriate includes just need to know how to get the isdigit to check the string and pull the numbers for display.
    thanks ahead of time.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    What? You are not making any sense as to what you want to do.
    Also, it is a good idea to replace char word[20] with std::string word and cin.getline(...) with std::getline(std::cin, word).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Math Parser thingy.....it's kinda cool
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 06-17-2005, 01:53 PM
  2. Dos Graphic....kinda
    By Xeavor in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 01:14 AM
  3. Kinda surprised no one has mentioned this ("Under God" Decision")
    By Thantos in forum A Brief History of Cprogramming.com
    Replies: 84
    Last Post: 06-21-2004, 08:45 PM
  4. Math question... kinda abstract
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-12-2003, 05:46 PM
  5. Video Game Violence - a new twist...kinda
    By Cshot in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 11-26-2002, 10:04 AM

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