7 ms·
Well no. What would you expect this code to do? void increment(int x) { x += 1; } void printit() { int y = 0; increment(y)
by ketralnis 11y ago
Well no. What would you expect this code to do?
void increment(int x) {
x += 1;
}
void printit() {
int y = 0;
increment(y);
printf("%d\n", y);
}
C doesn't have lists so I had to use an int here, but the Python example does the equivalent of that code printing 1, not 0. (But only for lists. That same Python code with ints does what you expect.)