|
#include "stdio.h"
#include "stdlib.h"
#include <time.h>
int main()
{
int i=1, n;
printf("Enter A Number That You Want to print");
scanf("%d", &n);
while(i <= n)
{
//srand( (unsigned)time( NULL ) );
printf("%7d", rand());
if(i%8 == 0)
putchar('\n');
i++;
}
printf("\n\n");
return 0;
}
-------------------------------------
소스를 보시면 아시겠지만 걍 랜덤함수로 입력받아서 출력하는 간단하 예제입니다.
여기서 그냥 rand()함수를 쓰면 계속해서 같은 수만 나오는데요...
이럴땐 srand(time(NULL))을 쓰면 된다는데....어떻게 쓴다는건지 모르겠네요..
//와같이 해도 하면..
error C2664: 'printf' : cannot convert parameter 2 from 'void' to '...'
Expressions of type void cannot be converted to other types
이런 오류 메세지가 뜨고...
답변 부탁드립니다.
아 그리고 이런문제가 발생하는 이유가 seed때문이라고 하시던데...seed가 뭔가요?
|