Thread: How to occurrence digits in string function.

  1. #1
    Registered User
    Join Date
    Oct 2010

    Question How to occurrence digits in string function.

    Hi everyone.
    Actually I'm still new in c++ programming.
    I want to create a program so that when a person input "122555abc", the output will be :

    Digits Occurrence
    1 1
    2 2
    5 3

    Did anyone can help me?

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Liverpool UK
    Well show your atempt so far
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Dec 2009
    Well here is the code to display the numbers in a string without any chars.

    for (i = 0; i < message.length(); i++)
          cout << message[i] << endl;
    This is only a start and is showing you how to loop through the string to search for digits.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polymorphism and generic lists
    By Shibby3 in forum C# Programming
    Replies: 9
    Last Post: 07-26-2010, 05:27 AM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM