https://cs50.harvard.edu/x/2023/sections/2/
#include <cs50.h>
#include <stdio.h>
int main(int argc, string argv[])
{
for (int i = 1; i < argc; i++)
{
printf("%c", argv[i][0]);
}
printf("\n");
}
출력예시
int main(int argc, string argv[]) 를 활용하면, command line argument를 활용한 프로그램 제작이 가능하다.
또한
그러나 argv는 모두 string 으로 입력되므로,
1024라고 입력해도 Int로 바로 사용이 불가하다.
int로 변환해서 사용해야함.
또한 argv array범위를 벗어나서 지정할 경우 메모리에 저장되어있는 예상할수 없는 값이 튀어나오니 주의해야 한다.