c++ - Why this code is printing 0 to 297 but not 0 to anything greater than 297? -


as can see, in code , im trying print 0 m . ive used "m" variable.(ignone "n", main thing "m" here) if input m = 5 ( accually type 4 input "n" in keyboard ignore , "m" 5 ) . code print 0 1 2 3 4 5 . problem face can see 0 m numbers when m 297 or less 297. when input m more 297 , example 500 . can see numbers 203 - 500 . why not seeing 0 - 500?

#include <bits/stdc++.h> using namespace std; int main() {   long n, m;     cin >> n;   m = n + 1;    vector<long> v(0);    (long = 0; < m; ++i) {     v.push_back(i);   }    (long j = 0; j < m; ++j) {     cout << (v.at(j)) << endl;   }   return 0; } 

this prints [0, 500] fine me it's scrollback limitation. check settings on terminal if you're using one.

if you're on unix-like system can use wc command count number of lines printed , confirm yourself:

$ echo "500" | ./a.out | wc -l 501 

you can send output less let scroll through it

$ echo "500" | ./a.out | less 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -