scanning the string

This is a discussion on scanning the string within the C Programming forums, part of the General Programming Boards category; Hello, I have a little question, I need to write a function which receives a string as a parameter (like ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 03:35 AM
  3. Scanning ...
    By whammy in forum C++ Programming
    Replies: 4
    Last Post: 11-03-2005, 05:25 PM
  4. scanning in character string
    By zackboll in forum C Programming
    Replies: 12
    Last Post: 11-24-2004, 01:18 AM
  5. scanning a string twice???
    By Lynux-Penguin in forum C Programming
    Replies: 7
    Last Post: 05-12-2002, 08:06 PM

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