#include <stdio.h>
char strings[] = "This is a apple.";
void main(void)
{
char* ptr;
char 문자;
while ()
{
printf( "\n % c", 문자);
}
}
제가 만들려고 하는 프로그램은
this is apple을
화면상에
t
h
i
s
i
s
a
p
p
l
e
이렇게 나오게 하고 싶은데 while함수랑 포인터함수를 활용하여 만들어야할것 같은데
어떤 방식으로 설계하면 좋을까요?
ptr에 string 넣고 while 조건에 *ptr 넣으셈(널문자 감지) 그리고 printf("%c\n", *ptr); 루프에 넣으면 끝
#include char strings[] = "This is a test.";void main(void){ char* ptr; ptr = strings; while (*ptr) { printf( "\n % c", *ptr); }} 이건가요?
아 맞다 printf에 *ptr이 아니라 *ptr++ 해야지 그럼 됨
띄어쓰기도 지워야겠네 while문쓸꺼면 break 조건도 주고 - dc App