1 Replies - 298 Views - Last Post: 15 January 2013 - 09:57 PM Rate Topic: -----

#1 xaib_xaib  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-January 13

how to get input in format 5:60:8 but only store the integers.

Posted 15 January 2013 - 09:45 PM

i need to make a program that gets input in format 8:7:60 but only processes the numbers. the 3 numbers are stored in 3 different variables.
Is This A Good Question/Topic? 0
  • +

Replies To: how to get input in format 5:60:8 but only store the integers.

#2 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1112
  • View blog
  • Posts: 4,619
  • Joined: 09-June 09

Re: how to get input in format 5:60:8 but only store the integers.

Posted 15 January 2013 - 09:57 PM

Check on the man page on scanf. You can suppress input by specifying a "*" before the format type specifier.

For example, the following will take the format of integer-character-integer while suppressing the character assignment.
int a, c;
scanf("%d%*c%d", &a, &c);


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1