Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11631

why is the desirable number not getting stored in C from the user input data [closed]

$
0
0

My goal is to use the property of scanf() function. I want to supress ':' in the input to get the hours and minutes value into their respective variables hours_var and minutes_var.

#include<stdio.h>#include<string.h>void main(){    int hours_var,minutes_var;    printf("Whats the time??\n");    scanf("%d*c%d",&hours_var,&minutes_var);    printf("%d\n", hours_var);    printf("%d\n",minutes_var);}

OUTPUT :

Whats the time??2:2420

I wanted 24 in the minutes_var variable . What did I miss??


Viewing all articles
Browse latest Browse all 11631

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>