I didn't realize you were so fragile.
You sure like name-calling, though.
Type: Posts; User: oogabooga
I didn't realize you were so fragile.
You sure like name-calling, though.
&& yields 1 if and only if both it's operands are non-zero; otherwise it yields 0.
|| yields 0 if and only if both of it's operands are 0; otherwise it yields 1.
Are you some kind of paranoid associativity fanboy? I think you mean precedence.
You need to consider the precedence and the parentheses. The part in the parens is computed first.
Within the parens, the && has higher precedence, so the first thing that's computed is 1 && 0,...
Firstly, remember that the equality operator is ==, not just =. You need to change this in your if conditions.
Even with this change it's difficult to understand what your code is trying to do....
You're not "assigning" it that value. You're "anding" that value with it's current value. CSIZE is a mask with 1's in the position of the bits that encode the characters size. By complementing that...
1.
Declare main as int main(void), not void main() (which is not a standard declaration and yields no benefit). And put a return 0 statement at the end of main.
2.
Remove the fflush(stdin) calls...
C99 has the z length modifier for the size_t type.
printf("%zu", strlen(str));
Without threads the program simply rotates around the various tasks, performing a little of each at a time, and it does it so quickly it looks like they're all happening at the same time.
However,...
@Soma,
I agree with pretty much all you said, though to ask what fflush(stdin) does is not relevant since it is presumably documented by MS. I don't know and I don't care because I've never used...
@Soma:
How can a
If it's undefined, it's undefined. Undefined means that the implementation is able to do absolutely anything it wants to. It's under no obligation to trash memory, erase the...
I don't feel you're being harsh or trying to start anything. :) I'm interested in this discussion and I know that I have it at least partly wrong.
I've been reading the standard lately and am...
I did "warn him off" by telling him it was non-portable.
"Undefined behavior" is a portability issue. That was my point.
I don't recall "teaching" (or using) fflush(stdin).
I realize that...
"Undefined behavior" simply means that the standard does not define a behavior for it. That's all. Any particular implementation is free to define a behavior for it and still perfectly conform to the...
To protect against such buffer overflows you can use fgets to read the file a line at a time. This function puts a limit on how much it reads, so it won't overflow the buffer. Since you have to pick...
You should include ctype.h (for isalpha and isdigit).
You should use getchar (instead of the non-standard getch).
spac is "unused" (and doesn't have enough space to hold a string with a single...
You talk about reading and writing to files as if that can't possibly affect any other variables. But if one of those reads overflows a buffer, that data can run into the other variables' memory.
...
Putting your code together with my changes and entering 20 and 100 yields:
+--------------------+
| |
| |
| |
| |...
You're running your function twice for each iteration.
Try this (untested) :
for(int i = 0; i < anzSchritte; i++){
if((nextStep(insectZeiger, laenge, raster)) == 3){
...
You have duplicate code. And you could use a switch.
int nextStep(struct Ameise* ant, int len, char antarena[][len]){
switch (antarena[ant->y][ant->x]) {
case ' ':
...
That's not what I grow. And it sounds like you might have been smoking a little of your imaginary "synthetic" marijuana.
Naaaaah, I'm just yankin' yer chain!
G'nite.
I'm glad you're getting all the evil mariHuana people off the streets.
I feel so much safer.
I don't find marijuana offensive.
Another common (and probably better) alternative is to have a separate List struct:
typedef struct List {
DLLNode *head;
DLLNode *tail;
size_t size;
} List;
You'd initialize...
Please post code that compiles, which means including all headers.
Even adding headers, you still have an error (DLLNode does not have a member called i).
And since you're compiling with -g,...