This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* int* const */ | |
#include<stdio.h> | |
int main(int * pArr, int n) { | |
int a = 10; | |
int b = 20; | |
int* const p = &a; | |
//p=&b -> Error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* const int* */ | |
#include<stdio.h> | |
int main(int * pArr, int n) { | |
int a = 10; | |
const int* p = &a; | |
//*p = 30; -> Error | |
a = 30; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Call by Reference*/ | |
#include<stdio.h> | |
void swap(int* a, int* b); | |
int main(int * pArr, int n) { | |
int val1 = 10; | |
int val2 = 20; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int ArrAdder(int* pArr, int n); | |
int main(int * pArr, int n) { | |
int arr[10] = { 1,2,3,4,5,6,7,8,9,10 }; | |
int SumOfArr; | |
SumOfArr = ArrAdder(arr, sizeof(arr) / sizeof(int)); | |
printf("배열의 총 합 : %d \n", SumOfArr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void fct(int *arr2); | |
int main(int * arr2) { | |
int arr1[2] = { 1,2 }; | |
fct(arr1); | |
printf("%d \n", arr1[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(void) { | |
char* arr[3] = { "fervent-lecture", "tcp/ip", "socket programming" }; | |
printf("%s \n", arr[0]); | |
printf("%s \n", arr[1]); | |
printf("%s \n", arr[2]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(void) { | |
int a = 10; | |
int b = 20; | |
int c = 30; | |
int* arr[3] = { &a, &b, &c }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
//def. this array is variable | |
char str1[5] = "abcd"; | |
//def. this array is number | |
char *str2 = "ABCD"; | |
printf("%s \n", str1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(void) { | |
int arr[2] = { 1,2 }; | |
int* pArr = arr; | |
//output by array name | |
printf("%d, %d \n", arr[0], *(arr + 1)); | |
//output by variable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(void) { | |
int arr[5] = { 1,2,3,4,5 }; | |
int* pArr = arr; | |
printf("%d \n", *pArr); | |
printf("%d \n", *(++pArr)); | |
printf("%d \n", *(++pArr)); | |
printf("%d \n", *(pArr+1)); |