# Search:

Type: Posts; User: Salem

Page 1 of 20 1

1. ## Thread: Issue with function calls

by Salem
Replies
1
Views
5

### > float mod,result; mod here is an...

> float mod,result;
mod here is an uninitialised local variable, and nothing to do with the result of the mod function you just called in main.

Maybe pass mod from main to this function as...
2. ## Thread: Very easy task with arrays, but a cannot do it

by Salem
Replies
5
Views
110

### > It needs to assign all nonzero values from 1st...

> It needs to assign all nonzero values from 1st array to 2nd, from left to right in ascending order and
> return number of significant ( that were assigned to 1st to 2nd ) elements of 2nd array. ...
3. ## Thread: Pass array pointer to function and compute size of array

by Salem
Replies
11
Views
114

### Pointers have no concept of the size of the thing...

Pointers have no concept of the size of the thing they point to.
If they did, unintentional buffer overflows would have been long banished to history.

void foo ( int *bar ) {
// no idea...
4. ## Thread: I need help with a little calculation on C

by Salem
Replies
4
Views
88

### Do you have code for that, or is it just a...

Do you have code for that, or is it just a screen-shot from your assignment.

> x1 should be 0.1 not 0.3

for (i = 0; i < b ; i++, x = xnew ) {
xnew = x + pow(c,i)* h;
// figure out...
5. ## Thread: I need help with a little calculation on C

by Salem
Replies
4
Views
88

### So this? for (i = 0; i < b ; i++) { x =...

So this?

for (i = 0; i < b ; i++) {
x = x + pow(c,i)* h;
y = (6 * pow(x,2) + 29*x + 14) / (32 - pow(x,5));
}

by Salem
Replies
3
Views
78

### for ( i = 15 ; i >= 0 ; i-- ) { if ( ++key[i]...

for ( i = 15 ; i >= 0 ; i-- ) {
if ( ++key[i] ) break;
// continues if a value rolls over from 0xff to 0x00
}
7. ## Thread: C - Stdin Buffer

by Salem
Replies
9
Views
164

### The buffering state of a stream is irrelevant to...

The buffering state of a stream is irrelevant to how a particular function operates with that stream.

fgets will read characters until the buffer is full, a \n is seen or end of file.
8. ## Thread: Consolidate multiple strings to a single one

by Salem
Replies
3
Views
112

### Well the first problem would be your broken loop,...

Well the first problem would be your broken loop, where you initialise i, but increment the uninitialised j
> for (i = 0; i < count; j++)

Before you create a mass of code, make a separate file...
9. ## Thread: A very SIMPLE program that is IMPOSSIBLE to create on Mac!

by Salem
Replies
6
Views
185

### Well you also need to link with the library as...

Well you also need to link with the library as well.

clang prog.c -lncurses
10. ## Thread: Valgrind complaining of unitialized variable with strstr

by Salem
Replies
2
Views
82

### char intermediary[len+1]; ...

char intermediary[len+1];
memcpy(intermediary,haystack,len);
a = strrchr(intermediary,'\"');

memcpy doesn't put \0 characters on the ends of strings.
11. ## Thread: A very SIMPLE program that is IMPOSSIBLE to create on Mac!

by Salem
Replies
6
Views
185

### 1. Ncurses has far more functionality than...

1. Ncurses has far more functionality than conio.h ever had. All you need to do is look.

For example, getting a character without waiting.
c - how to get a character from stdin without waiting...
12. ## Thread: Consolidate multiple strings to a single one

by Salem
Replies
3
Views
112

### Your sort loop is on the right track. if...

Your sort loop is on the right track.

if (strcmp(contacts[i].firstname, contacts[j].firstname) > 0) {
struct phonebook temp = contacts[i];
contacts[i] = contacts[j];
contacts[j] = temp;...
13. ## Thread: strcpy not overwriting (segmentation fault)

by Salem
Replies
2
Views
109

### All string constants are in read-only memory, so...

All string constants are in read-only memory, so you get a segfault if you try to write to them.

str2 = " Long text 1";
This works because all you're doing is setting a pointer to point to...
14. ## Thread: Circular rotation pf string array

by Salem
Replies
4
Views
130

### > arr[0]=tempfirst; These things should be...

> arr[0]=tempfirst;
These things should be outside your loops.
You want to do them last, after you've moved the whole array.

by Salem
Replies
2
Views
158

### You just did.

You just did.
16. ## Thread: Running time difference

by Salem
Replies
4
Views
125

### Well the OS has to physically map the 400MB of...

Well the OS has to physically map the 400MB of memory you basically use as write-only memory.

That's a lot of memory to write once, read once from.
17. ## Thread: Need guidance on how to make a rectangle be printed with two characters

by Salem
Replies
6
Views
325

### Cross-posted here -> Need guidance on how to make...

Cross-posted here -> Need guidance on how to make a rectangle - C++ Forum
18. ## Thread: Need Some explanation for this program output

by Salem
Replies
3
Views
122

### I'm pretty sure all that nonsense results in...

I'm pretty sure all that nonsense results in undefined behaviour.
19. ## Thread: Random Number Generator

by Salem
Replies
3
Views
151

### Do something like rand() % 100

Do something like
rand() % 100
20. ## Thread: Strings and Ints through pipes between processes.

by Salem
Replies
1
Views
105

### Before the exec call, do this ...

Before the exec call, do this

This will join the appropriate end of the pipe to the stdin of the child process.
21. ## Thread: Function not returning date string

by Salem
Replies
2
Views
130

### Duplicate Function not returning date string...

Duplicate
Function not returning date string
22. ## Thread: srand and Random number generator

by Salem
Replies
14
Views
326

### Your first cut of C code should look like this....

Your first cut of C code should look like this.
It's basically all the bullet points of your assignment written as comments.

int main ( ) {
// a) Allow the user to enter their own...
23. ## Thread: functions with char pointer

by Salem
Replies
3
Views
155

### Well you could step through the code with a...

Well you could step through the code with a debugger.

Like I did.

\$ gcc -g foo.c
\$ gdb -q ./a.out
(gdb) b substr
Breakpoint 1 at 0x4008b9: file foo.c,...
24. ## Thread: functions with char pointer

by Salem
Replies
3
Views
155

### So what's an example of a test case that you...

So what's an example of a test case that you think should pass, but actually fails?

by Salem
Replies
5
Views
320