新明解c言語中級編を学んでいたところ、次のコードでエラーが起こりました。
c
1#include <stdio.h> 2#include <time.h> 3 4 5int sleep(unsigned long x) 6{ 7 clock_t c1 = clock(), c2; 8 9 do { 10 if ((c2 = clock()) == (clock_t)-1) 11 return 0; 12 } while (1000.0 * (c2 -c1) / CLOCKS_PER_SEC < x); 13 return 1; 14 15} 16 17int main(void) 18{ 19 printf("My name is BohYoh."); 20 fflush(stdout); 21 22 sleep((long)2000); 23 printf("\rHow do you do? "); 24 fflush(stdout); 25 26 sleep((long)2000); 27 printf("\rThanks. "); 28 29 return 0; 30} 31
エラーの内容は、Conflicting types for 'sleep'です。
united.h がインクルードされていないからだと考え、インクルードしましたが、またsleepの型が衝突しました。
原因と解決法をご教授願います。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/22 14:02