Yurttas/PL/OOL/Cplusplus/F/06/02/01/00/io gs 00.cpp

 1/*
 2   Copyright(C) 2005
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : September 1, 2005.
11   authorĀ : Salih Yurttas.
12
13   io_gs_00.cpp
14*/
15
16
17#include <iostream>
18#include <string>
19
20#include <cstdlib>
21
22using namespace std;
23
24int main(int argc, char* argv[]) {
25
26  char s[] = "4 8 2";
27
28  int a, b, c;
29
30  sscanf(s,"%d %d %d ",&a,&b,&c);
31
32  cout << a << ", " << b << ", " << c << endl;
33
34  string sa = s;
35
36  sscanf(sa.c_str(),"%d %d %d ",&a,&b,&c);
37
38  cout << a << ", " << b << ", " << c << endl;
39
40}