Why would it? You're not assigning anything, you're just doing the subtractions.
Type: Posts; User: erikkonstas
Why would it? You're not assigning anything, you're just doing the subtractions.
That's not a zero, that's the character code of '0', which in ASCII is 48, and all of the digits are in order ('1' is 49, '2' is 50, ..., '9' is 57). To append a digit to tmp, you multiply it by 10...
To add to Salem's post, the "int a[n]" syntax creates what is known as a Variable-Length Array (VLA) which is not necessarily supported (you can read more about possible shortcomings here).
...
Another way to tackle the scanf problem is to add a space after "%d", so this
scanf("%d", &age);
turns into this
scanf("%d ", &age);
head isn't a PPMHead, but an array of PPMHead. You have to initialize each element of head separately (that is, the members of head[0], the members of head[1], etc.), and in a function (not outside...
Initializing a struct means initializing each of its members, for example:
#include <stdio.h>
typedef struct
{
int x;
int y;
int z;
I can see that you're using head[0].width and head[0].height without initializing head, which means they're always zero, as head is global. This means that your loops do not execute even a single...
By the way, the two output sides might be different, but they will always be the same every time the program is ran if you don't use srand. For example, in my case, your original code output Tails...
Um I didn't say anything different than john.c...?
Yes, in fact, global variables are stored in a separate part of memory on their own. Note that a global variable isn't the only kind of "a variable that will not get destroyed", but it's the only...
Nope. You have to declare it with extern in every compiled file (after preprocessing, so if you just declare it in a header you include in every file, you're OK).
I can, too!
Nope, everything should be an int here, especially since % is used.
Hm, I wanted to emphasize laserlight's point above; you do not want to compute the file size beforehand! Who knows what your function will accept as its argument? What if it receives STDIN, for...
Hm, can you mention why you'd want to do this? The text "width" you're talking about depends completely on the font the text is written in; for example, on a terminal, the font will most likely be...
Depending on how the "array" is declared, it can also mean that what you pass to sizeof might be a pointer so it returns that size, not the array's! We really need to see more code to be sure what's...
Can you clarify this, please? I can't understand exactly what you want to do.
Hi, can you show what you've done so far? We don't generally do other peoples' homework entirely.
Yep, that's exactly my point about Sedgewick. So I checked again, we're actually using the THIRD edition at university, and the thing where the text and the code differ a lot semantically is very...
On top of that, it appears that you've copied your code incorrectly here, because I can see a missing ) on line 29.
Yeah... I happen to be experiencing Sedgewick's snippets from this very book (second edition, current university professor is using it) and his coding style is HORRENDOUS!!! Globals everywhere (in...
1. argv is actually an array of pointers to char (char *), the first of which is at the memory address in the argv variable itself, which is why you're "requesting another pointer". Each of these...
I want to point out that setting i to values above 0 does actually do something bad in your case: if your string's length is less than the initial value of i, you will be accessing memory you...
Hm, bummer. I was trying to write some test project which has a lot of functions and decided to split them in a few .c files but I guess I'll have to do either of these two. Thanks for answering,...
Let's say I have a file f1.c with the following:
int two(int a, int b) {
return a + b;
}And a file f1.h with the following:
int two(int, int);And a file f2.c with the following:
#include...