View Single Post
Vampyre747 is offline
Jan19-09, 02:59 AM
P: 4
I see that you have the scanf line commented out. You can look at a reference for scanf such as this page. There's more than one way you could do this. You could use the %u, %x or %s format specifiers. If you use %s, you will have to use something like atoi to convert it to a number. After you retrieve the user's value, you have to do range checking. You could just do a do/while loop for this - just terminate the loop when the values are valid. Something like this would work:

do {
printf("Enter the red component's value:");
scanf(%u, &red);
} while (red <= 255);

You can just Google line-drawing algorithms. One of the first pages that pops up is If you are going to delve much deeper into graphics code, you probably want to check out some books specifically on graphics programming.