C question
1
Name:
Anonymous
2009-05-26 12:38
What's the difference between writing int frozen() and int frozen(void) ?
2
Name:
Anonymous
2009-05-26 12:41
What's the difference between writing int frozen() and int ?
One is a function declaration and the other is just a datatype.
3
Name:
Anonymous
2009-05-26 12:42
inb4 shitty punchline involving a certain tripfriend.
4
Name:
Anonymous
2009-05-26 12:43
5
Name:
Anonymous
2009-05-26 12:55
Okay, one more thing;
#include <stdio.h>
#include <stdlib.h>
struct foo
{
char fooc[20];
int fooi;
};
main()
{
foo *bar;
bar = (struct foo *) malloc(sizeof(foo));
bar->fooi = 16;
bar->fooc = "ANUX";
}
Why doesn't the bar->fooc assignment work? Sorry, I'm new to C.
6
Name:
Anonymous
2009-05-26 12:59
>>5
because that's what strncpy() is for
7
Name:
Anonymous
2009-05-26 13:06
8
Name:
Anonymous
2009-05-26 13:16
9
Name:
Anonymous
2009-05-26 13:29
>>7
FAQ THAT FAQ . They use non-standard faggot quotes. Hardly a document of any worth.
10
Name:
Anonymous
2009-05-26 13:30
11
Name:
Anonymous
2009-05-26 13:48
>>9
How are they ``nonstandard''?
>>2
main() vs main(void)
Seriously.
12
Name:
Anonymous
2009-05-26 13:50
>>9
Have you read your
The M4 macro processor today?
>>11
main() vs main(void)
Lurk more.
Seriously.
13
Name:
Anonymous
2009-05-26 15:10
>>1
Your argument boils down to the fact that you suck at LISP and/or don't understand how computers work?
Look, there's no conflict between C and Lisp. If you want attention that badly, find a real issue to argue about.
14
Name:
Anonymous
2009-05-26 15:51
>>11
They're nonstandard because they are not valid English quotes.
>>12
No, I do not read documents that contain faggot quotes, as they are nonstandard,
unscientific , and
ultimately destructive .
15
Name:
Anonymous
2009-05-26 16:08
>>14
Is that even relevant to the topic, or is it just your way to say ``I haven't read SICP''?
16
Name:
Anonymous
2009-05-26 16:59
if you declare a function as
int frozen();
then you can do call it with
frozen("faggot", 32, stdout);
which you can't do if you declare it as
int frozen(void);
now fuck off.
17
Name:
Anonymous
2009-05-26 17:17
18
Name:
Anonymous
2009-05-26 17:21
19
Name:
Anonymous
2009-05-26 18:06
>>16
That makes
no sense . Is this really what you can do in C? Holy shit.
Why would you be able to call a function with parameters when the declaration has none?
20
Name:
Anonymous
2009-05-26 18:08
>>19
so that the room is empty
21
Name:
Anonymous
2009-05-26 18:44
22
Name:
Anonymous
2009-05-26 18:45
Another question;
I want the program to print lines of text, one at the time, after pressing enter. I thought of putting some moot scanfs between the printfs. Is there a better way to do this?
23
Name:
Anonymous
2009-05-26 18:55
getchar
24
Name:
Anonymous
2009-05-26 19:01
>>23
Thank you. I'll be sure to post more exciting questions in the future!
25
Name:
Anonymous
2009-05-26 19:22
>>19
int frozen(); doesn't mean it has no parameters, just as
frozen(void); doesn't mean it has no return type.
26
Name:
Anonymous
2009-05-26 19:30
>>15
No, you put direct quotations in quotes, e.g. "Is that your way of saying 'I haven't read SICP'?"
This makes it a valid quotation.
27
Name:
Anonymous
2009-05-26 19:31
>>19
Putting 0 parameters in a declaration means the number of parameters is unknown
>>5
Also, don't cast pointers in C.
28
Name:
Anonymous
2009-05-26 20:11
>>27
Also, don't cast pointers in C.
You mean Sepples.
29
Name:
Anonymous
2009-05-26 20:14
>>27
Also, don't cast pointers in C.
Enjoy not doing anything useful ever.
30
Name:
Anonymous
2009-05-26 20:30
>>29
I will, along with my job.
31
Name:
Anonymous
2009-05-26 20:31
>>29
You don't even understand the advice, do you?
32
Name:
Anonymous
2009-05-26 22:04
whats the difference between
int frozen()
int __pascal frozen()
33
Name:
Anonymous
2009-05-26 22:21
>>32
Nothing
Wi rth mentioning.
34
Name:
Anonymous
2009-05-26 23:40
>>33
Sharp like a
C , I see.
35
Name:
Anonymous
2009-05-27 3:47
>>7
Please, moar such links.
36
Name:
Anonymous
2009-05-27 3:54
37
Name:
Anonymous
2009-05-27 4:11
38
Name:
Anonymous
2009-05-27 5:29
39
Name:
Anonymous
2009-05-27 6:34
>>29
Casting pointers is part of the power of C, but it's something that should be done rarely. Casting the return value of malloc() is bad, and a simple google will show the dozens of reasons for it.
40
Name:
Anonymous
2009-05-27 16:00
There should be more threads like this on /prog/, helpful and insightful.
Newer Posts