# Search:

Type: Posts; User: laserlight

Page 1 of 20 1

1. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### That's because you didn't implement the algorithm...

That's because you didn't implement the algorithm correctly. Look carefully at what should be in which loop.
2. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### Instead of guessing, why don't you go through the...

Instead of guessing, why don't you go through the algorithm with unsorted input and see what you get, and then implement it and try it for an unsorted array to confirm?
3. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### There is a small but critical piece missing...

There is a small but critical piece missing though: after counting with the inner loop, I must be set to J in order to skip those elements that have already been counted.
4. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### Suppose you had input like this: 1 1 1 2 2 3 3 4...

Suppose you had input like this:
1 1 1 2 2 3 3 4 4 4 5
Now, if you want to count the input, it's quite easy: you start with the first number, and set count=1. Then you keep looping over the...
5. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### With the first approach, start by sorting the...

With the first approach, start by sorting the array. Don't worry about the counting yet. You can use the qsort function, or implement your own sort.
6. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### That usually doesn't make sense: the point of...

That usually doesn't make sense: the point of using the static keyword is to give the function name internal linkage. If you declare it in a header, then you're saying that in every separate source...
7. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### Which approach are you trying to implement? I...

Which approach are you trying to implement? I outlined two ways:

1. Sort then make a single pass to count consecutive numbers of the same value.

2. Use a second array to map the numbers to...
8. ## Thread: What is the difference between declaring global or static local variables ?

by laserlight
Replies
2
Views
97

### 1. A static local variable has persistent state...

1. A static local variable has persistent state (due to static storage duration), but local scope. So you avoid name collisions and can manage the state in a more restricted portion of the program...
9. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### Refer to my post #4.

Refer to my post #4.
10. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### That's because you start i at 1 instead of 0.

That's because you start i at 1 instead of 0.
11. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### It looks like you're practically there. Just...

It looks like you're practically there. Just print something indicating that the numbers are repeated.

If you mean repeated more than once in that the numbers have to appear three or more times,...
12. ## Thread: how to compare element of array with other element

by laserlight
Replies
23
Views
446

### Use nested for loops. That's where your j...

Use nested for loops. That's where your j variable can come into play.
13. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### This is a very good opportunity to start though:...

This is a very good opportunity to start though: you're writing a self-contained library such that you don't have to worry about things like mocking a database or a server. Plus it'll look good on...
14. ## Thread: split char array, store and return it

by laserlight
Replies
3
Views
168

### You're welcome. Declaring a function static...

You're welcome.

Declaring a function static affects the linkage of its name. That is, instead of the name referring to that function in all translation units (external linkage, which is the...
15. ## Thread: Prime Factor

by laserlight
Replies
3
Views
127

### Suntani: you posted this twice, and it looks like...

Suntani: you posted this twice, and it looks like you copied and pasted this from somewhere such that you both asked a question and then appear to address the question. Presently, you're giving me...
16. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### Glad to hear that you found and fixed that. ...

Glad to hear that you found and fixed that.

Going back to something I think I've mentioned to you before: have you considered automated unit testing? Right now you have what might be called an...
17. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### Well, I'm clearly not the only one who disagrees...

Well, I'm clearly not the only one who disagrees with you: the experts on the C and C++ standards committees disagree with you that this constitutes a significant attack vector. If not, it would be a...
18. ## Thread: Help on reading correctly the image...

by laserlight
Replies
10
Views
268

### What is your current code?

What is your current code?
19. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### It's not clear to me how that attack would work...

It's not clear to me how that attack would work in practice without leveraging on another vulnerability, e.g., a typical buffer overflow vulnerability.

So no, I don't think this warrants...
20. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### Such helper functions make your code more...

Such helper functions make your code more readable. It's true that there might be function call overhead, but on the other hand for functions that aren't good candidates for inlining such overhead is...
21. ## Thread: split char array, store and return it

by laserlight
Replies
3
Views
168

### This is wrong: static char t[sizeof(*word)] =...

This is wrong:

static char t[sizeof(*word)] = "";
word is a pointer to char, so sizeof(*word) is equal to 1. Hence, t is an array of char that is only large enough to store an empty string.

If...
22. ## Thread: trying to read numbers from a file - only getting zeros

by laserlight
Replies
4
Views
155

### I'd suggest reading in a single pass instead. Do...

I'd suggest reading in a single pass instead. Do this by reading line by line into a sufficiently long string. Check if the line begins with a '#', and if so, you can skip it. Otherwise, parse it for...
23. ## Thread: I dont know whats going on with my program

by laserlight
Replies
6
Views
424

### davic01: is this supposed to be a C program or a...

davic01: is this supposed to be a C program or a C++ program?
24. ## Thread: Wierd bug in bignum left shift function

by laserlight
Replies
35
Views
472

### For alu_vec, have you considered moving expand...

For alu_vec, have you considered moving expand and shrink into their own functions? For example:

static int _alu_vec_expand( alu_vec_t *vec, int want, size_t perN, int dir, int used )
{
int...
25. ## Thread: Casting an array problem from unsigned int to uint8_t

by laserlight
Replies
3
Views
199

### Maybe the problem lies with the printing of the...

Maybe the problem lies with the printing of the output.

I suggest that you post the smallest and simplest compilable program that demonstrates this problem.
Results 1 to 25 of 497
Page 1 of 20 1