Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Using `scanf` for `unsigned long long int` with MinGW.

$
0
0
#include <stdio.h>
int main (void) {
   int t;
   int y, z, a, b;
   scanf ("%i", &t);
   for (t; t > 0 ;) {
      scanf ("%i", &y);
      --t;
   } 
   return 0;
}

The above code works fine and the program ends after I input t integers. But I want the program to allow me to enter larger positive integers, so I modified the code to this :

#include <stdio.h>
int main (void) {
   unsigned long long int t;
   int y, z, a, b;
   scanf ("%llu", &t);
   for (t; t > 0 ;) {
      scanf ("%i", &y);
      --t;
   } 
   return 0;
}

According to the code, if I enter 5, it should then allo me to enter 5 more integers, but instead I can enter as amny integers as I want. It seems that the for loop is not ending. Don't know why.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



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