Need quick C help please

Bluga

Banned
Nov 28, 2000
4,315
0
0
#1: Will the following print to file or stdout?

fprintf(stdout, "vertices=%d", graph(graph));

#2: Are these two the same?

int main (int argc, char **argv)

int main (int argc, char argv[])

#3: The following is a pointer to void, but what does it mean?

void *data
 

manly

Lifer
Jan 25, 2000
13,589
4,239
136
Do your own homework. :p I would recommend picking up a copy of K&R The C Programming Language. K&R are the creators of C.

1. Hint:

man fprintf
man stdout

2. No. You need to understand the correspondence between an array type and a pointer though. Any decent C book will cover this issue.

3. A void pointer is a generic pointer that can be assigned with *any* pointer type. However, you can't do much with a void pointer unless you cast it to a real pointer type.

man malloc to see a common usage of void *

Edit:
Damn you're fast Nothinman!
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
for item #1 - write a quick and dirty to test your conditions. You will find this method actually teaches you something and is usally faster than post a requst for help and waiting for responses.

Post requests for hard problems, not homework solving problems.
 

HJB417

Senior member
Dec 31, 2000
763
0
0
I like question #3. I'm a cs major and I was never taught about the pointer to void. That is very new to me. We were taught that void = nothing. Looks like I need to do a selfevaluation.