Tuesday 17 September 2013

error: ISO C forbids comparison between pointer and integer

error: ISO C forbids comparison between pointer and integer

I am brand new to programming and I have just finished reading the Book C
for Dummies by Dan Gookin. But I thought I am trying to make tiny programs
to get a feel of the language.
I learned that there is a random counter in C (which is not that random),
and apparently using the computers internal clock helps making the random
counter more random. I saw a code example in the book and it work when I
want to printf() random numbers in a grid. But now I would like the
program to limit it to only 3 numbers but instead of printing out the
numbers in digits I'm interested in learning how to have the computer
return printf() functions in a random manner. It doesn't have to be
printf() it really can be any function, but this seems to be the easiest
way to check.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int rnd(int range);
void seedrnd(void);
int main()
{
int x;
seedrnd();
for(x=0;x<1;x++)
// printf("%i\t" ,rnd(3));
if(seedrnd==0)
printf("Zero");
else if(seedrnd==1)
printf("One");
else
printf("Two");
return(0);
}
int rnd(int range)
{
int r;
r=rand()%range;
return(r);
}
void seedrnd(void)
{
srand((unsigned)time(NULL));
}

No comments:

Post a Comment