Searching within strings

This is a discussion on Searching within strings within the C Programming forums, part of the General Programming Boards category; I am trying to write a math engine. The problem I've encountered is that if a user enters say: add(12345,12345) ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    103

    Searching within strings

    I am trying to write a math engine. The problem I've encountered is that if a user enters say:
    add(12345,12345)
    then how do I know how many digits to read.
    Any solutions?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,255
    You read until there are no more digits left to read. isdigit() would be a helpful function in parsing this out.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could use some fancy sscanf work if they're going to be using a standard format.

    <operator><paren><op1><,><op2><paren>


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    29

    Question huh?

    Quote Originally Posted by Poincare View Post
    I am trying to write a math engine. The problem I've encountered is that if a user enters say:
    add(12345,12345)
    then how do I know how many digits to read.
    Any solutions?
    It seems to me that if you are inputting strings you will want to worry about this, but why wouldn't you use floats or ints or something else that isn't a string for your input?

    - Edward

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  2. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 10:41 PM
  3. Searching and matching strings: segmentation fault
    By Smola in forum C Programming
    Replies: 18
    Last Post: 07-11-2005, 01:25 AM
  4. Ofstream, Ifstream, Searching files for strings?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 04-04-2005, 04:45 PM
  5. Searching and Comparing Strings Using Parsing
    By niroopan in forum C++ Programming
    Replies: 3
    Last Post: 09-28-2002, 11:18 AM

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