Thread: scanning the string

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    5

    scanning the string

    Hello, I have a little question, I need to write a function which receives a string as a parameter (like molecular formula "H2O, C6H12O6, ..." ) and has to do 2 things:
    1: has to check that an element always starts with a capital letter and may be followed by a single lower case character like Fe2O3
    2:the abscence of a number indicates a single atom of that element. for example CO2

    I was thinking of using string length method but don't seem to have any luck, any ideas?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scanning string arrays from file
    By SimonBones in forum C Programming
    Replies: 4
    Last Post: 10-09-2011, 02:55 PM
  2. scanning and printing a string
    By Prestige in forum C Programming
    Replies: 5
    Last Post: 12-16-2010, 04:35 AM
  3. Scanning ...
    By whammy in forum C++ Programming
    Replies: 4
    Last Post: 11-03-2005, 06:25 PM
  4. scanning in character string
    By zackboll in forum C Programming
    Replies: 12
    Last Post: 11-24-2004, 02:18 AM
  5. scanning a string twice???
    By Lynux-Penguin in forum C Programming
    Replies: 7
    Last Post: 05-12-2002, 08:06 PM