0
Arrays
How to add a value from user into a array?
4 Respostas
+ 5
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>array;
int element;
while(cin>>element){
array.push_back(element);
}
return 0;
}
This will add all the integer values from the user separate by space into an array.
0
If you have a fixed length array then you could do:
int nums[] = { -1, -1, -1 };
nums[0] = usersInput;
Where -1 is no input yet provided.
0
Kai Harrison Why not just do it like this if it's a fixed length......
int nums[3];
0
Jan Nothing’s stopping you 😃