어제 내용 복습 중 알아낸 것
undefined reference to `get_string'
에러 시 해결 방법 :
$ clang prc.c -lcs50 -o prc
이렇게 컴파일링 해본다.
실행했던 코드 :
#include <cs50.h>
#include <stdio.h>
int main(void){
string animal = get_string("What is your favorite animal?\n");
printf("my favorite animal is, %s\n", animal);
}
What is your favorite animal?
monkey
my favorite animal is, monkey
간단한 c코드였지만 에러가 어제부터 나서 맥 문제인 줄 알았는데 스택오버플로어에 여러 해답이 있었다.
#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
string s = get_string("Before: ");
printf("After: ");
for (int i = 0, n = strlen(s); i < n; i++)
{
printf("%c", toupper(s[i]));
}
printf("\n");
}
Before: apple
After: APPLE