online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> void print_square(int x[]); int main() { int base[5] = {31,71,21,41,51}; printf("%p \n", base); for(int i = 0; i < 5; i++){ printf("%d ", base[i]); } printf("\n"); print_square(base); // base 배열명 자체가 주소라서 그대로 넣는다. //함수를 반복문 돌리는것보다 함수안에서 하는게 좋다. for(int i = 0; i < 5; i++){ printf("%d ", base[i]); } return 0; } void print_square(int x[]){ // 배열을 매개변수로 받을때는 []을 꼭 써줘야한다. printf("%p \n", x); // 주소가 같다. for(int i = 0; i < 5; i++){ x[i] += 10; } } // 매개변수에는 반드시 주소가 들어가야한다. // call by reference 개념이다. // 매개인자로 주소가 전달된다면 값이 바뀔수 있다. // 매개인자가 주소가 아니라면 절대 바꿀수없다. // *base는 base[0]과 같다 // *(base+1)은 base[1]과 같다. // +1을 할 때 자료형이 int라면 4바이트를 곱해 계산된다.

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue