error in n00b code

For everything else. All non-english posts will be either moved or deleted.
User avatar
Tumppi
Regular
Regular
Posts: 163
Joined: Wed Nov 19, 2003 6:47 pm
Location: Finland, Espoo
Contact:

error in n00b code

Postby Tumppi » Mon Jun 07, 2004 4:05 pm

Can somebody tell me what's wrong with this code:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
int luku;
int arvaukset=1;
int vastattu;
char vastaus[80];

printf("Tervetuloa Tumpin arvauspeliin!\n");
printf("Kysyn sinulta nyt tiettyä numeroa 0-1000 väliltä.\n");
printf("Jokaisen arvauksen jälkeen arvausmääräsi nousee yhdellä ja minä kerron sinulle oliko arvaamasi luku suurempi vai pienempi kuin ajattelemani luku.");

srand((unsinged int)time((time_t *)NULL));

luku=(rand()%1000)+1;

while(vastattu!=luku)
{
clrscr();
printf("Arvaa luku 1-1000.");
gets (vastaus);
vastattu=atoi(vastaus);

if (vastattu<luku) printf("Sinä vastasit: %d, joka on pienempi kuin oikea luku\n",vastattu);
else if (vastattu>luku) printf("Sinä vastasit: %d, joka on suurempi kuin oikea luku\n",vastattu);
else printf("Sinä vastasit: %d, joka on täsmälleen oikea luku!\n",vastattu);


arvaukset+1;
}
}


It's probably something very easy to find but not for me as I just started programming couple of weeks ago :). If you need to know any more details just ask. The text is in finnish but you don't have to know what it means to solve this problem. This is my first program with 'REAL 'programming language

I think there's something wrong with the

Code: Select all

srand((unsinged int)time((time_t *)NULL));
luku=(rand()%1000)+1;


Any ideas how to solve this?

EDIT:Sorry, founded it already.
Answer: unsinged --> unsigned
:)
User avatar
Dragst
Crew
Crew
Posts: 848
Joined: Tue Nov 18, 2003 5:41 pm
Location: Vantaa, Finland
Contact:

Postby Dragst » Mon Jun 07, 2004 10:33 pm

lol, ok =)
User avatar
Ezko
Veteran
Veteran
Posts: 372
Joined: Sun Dec 14, 2003 11:00 am
Location: Vantaa, Finland
Contact:

Postby Ezko » Wed Sep 08, 2004 8:08 am

Maybe this someone could close this?
Triplane ROCKS!!!
User avatar
TZ
Scarred Veteran
Scarred Veteran
Posts: 1033
Joined: Wed Nov 19, 2003 4:41 pm
Location: Nurkka
Contact:

Postby TZ » Wed Sep 08, 2004 2:47 pm

Well there would have been no reason to close this if people would have just let this topic to die peacefully. Oh well.
The post above should not be taken seriously.

Return to “Off topic, english only”

Who is online

Users browsing this forum: No registered users and 1 guest