Thread: string containing different variables

  1. #1
    Unregistered
    Guest

    Question string containing different variables

    Hi, my problem is this

    If have the following string "3$2$1924$20"

    and variables

    char var_a;
    unsigned int var_b, var_c;
    long int var_d;

    how can i assign var_a=3, var_b=2, var_c=1924, var_d=20?

    Thanks.

    A.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Code:
    sscanf ( array, "%c$%u$%u$%ld", 
             &var_a, &var_b, &var_c, &var_d );
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using SSCANF input string output two variables
    By kevndale79 in forum C Programming
    Replies: 9
    Last Post: 10-02-2006, 02:57 PM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. Another overloading "<<" problem
    By alphaoide in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2003, 10:32 AM
  5. "Operator must be a member function..." (Error)
    By Magos in forum C++ Programming
    Replies: 16
    Last Post: 10-28-2002, 02:54 PM