Having trouble with random number guesser

There were some weird things going on
I am using microsoft visual studio 2013
I have done some programming before and am somewhat experienced
I see nothin wrong with this code
PLEASE HELP

errors are:
strand is undefined
cannot open stdafx.h


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdafx.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
	int inumber, iguess;
	char y, n;

	inumber = rand() % 100 + 1;

	strand (time(NULL));

	do 
	{
		printf("Guess the number (1-100)");
		scanf ("id, &inumber");
		if (inumber < iguess) puts ("The number is lower");
		if (inumber > iguess) puts("The number is higher");
	} while (inumber = iguess);
	
	puts("Congratulations/nWould you like to play again?(y\n)/n/n");
	scanf("id, &y,&n");
	
	do 
	{
		int main();
	} while (y = y);

	do
	{
		return 0;
	} while (n = n);


}
1. change strand to srand
http://www.cplusplus.com/reference/cstdlib/srand/

2. Remove: #include <stdafx.h>
If your compiler complains that stdafx.h is missing, right click on your project in the solution explorer and you'll find an option to select "Not using pre-compiled headers". Ensure to select that one.
Also generally speaking you should get a seed before creating a random number or the first random number will be the same every time you run the program. Also I would suggest maybe using sub functions instead of the main function.

also line 28 you don't say the return type of a function when you call it. that would be like saying: unsigned int rand()... ect.. You only need the return type for prototyping and defining functions.
Topic archived. No new replies allowed.