キーボードから入力した文字を実行例のようにしたいです。どなたかお願いします。 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h>
キーボードから入力した文字を実行例のようにしたいです。どなたかお願いします。 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int strlen(const char *s) { int len = 0; while (*s != '\0') { len++; s++; } return len; } int main(void) { char str[20]; char *p; int i; int length; printf("キーボードからの入力:"); scanf("%s", str); p = &str[0]; length = strlen(str); while ( ① ) { for ( ② ) { ③; } ④; ⑤; } return 0; } (実行例) ーーーーーーー出力ーーーーーーー キーボードからの入力:abcdefg abcdefg abcdef abcde abcd abc ab a
ベストアンサー
(1149977903さん) while (length>0) { for (i=0;i<length;i++) { putchar(str[i]); } putchar('\n'); length--; }
質問者からのお礼コメント
ありがとうございます!
お礼日時:5/25 0:54