본문 바로가기
배워보자!!/c언어

[c언어] 문자 배열에 넣기!

by norinda 2015. 5. 3.
728x90

배열에 문자 하나하나 입력해 넣어

차례대로 출력해보겠습니다.


getchar() 함수는 "표준 입력 스트림(stdin)으로부터 한 문자를 입력받아서 반환해 주는 함수입니다.



#include <stdio.h>

#include <string.h>

#include <stdlib.h>


int main()

{  

char string[50];

int len , i;

int total = 0;

char c;

int count=0;

while((string[count++] = getchar())!='\n');


for (i = 0; string[i]!='\n'; i++)

{

printf("%c%d //" , string[i],string[i]);

}

return 0;

}






반응형

댓글