+ 1

Adding a numer to an array in c++

in a c++ program i found a line like this " b=c+1" where c is an array (1 dimension) what does it mean? i'm pretty sure that doesn't add 1 to all array's elements, but i don't know what this line does in the program. thanks for replies

18th Jul 2017, 2:57 PM
fede c
fede c - avatar
8 Answers
+ 1
#include<iostream> using namespace std; int a=3; void f(int b, int c[], int d) { while(d>=0){ c[d]=c[d]+d+b; d--; } a=6; } int main() { int a=1,b=2,c[]={3,4,5,6}; f(a,c+1,b); a+=2; c[0]=a-3; cout << c[0] << " " << c[1] << " " << c[2] << " " << c[3] << endl; cout << a << " " << b << " " << endl; return 0; } this is the code
18th Jul 2017, 3:16 PM
fede c
fede c - avatar
+ 1
but what does it mean to add a number to a vector? wich is the effect?
18th Jul 2017, 3:46 PM
fede c
fede c - avatar
0
Thanks a lot for the example! i understood the difference
18th Jul 2017, 4:04 PM
fede c
fede c - avatar