Reputation: 359
I am working on an app and I don't know why when I am printing my vector it shows the numbers "1 2 3 4" and at the end it shows a "%" like "1 2 3 4 %"
I will give you a code example
#include <stdio.h>
#include <vector>
using namespace std;
int n;
vector<int> soldati;
int main(){
scanf ("%d", &n);
for (int i = 1; i <= n; i++){
soldati.push_back(i);
}
for (int i = 0; i < soldati.size(); i++){
printf("%d ", soldati[i]);
}
return 0;
}
And here is what is shows when I run it.
I am giving a link because I can't post photos.
Upvotes: 1
Views: 57
Reputation: 40754
'%' comes from your shell.
You can add printf("\n")
at the end to clearly seperate your output and your shell prompt.
Upvotes: 5