# Search:

Type: Posts; User: Salem

Page 1 of 20 1

1. ## Thread: I need help with a little calculation on C

by Salem
Replies
4
Views
80

### 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...
2. ## Thread: I need help with a little calculation on C

by Salem
Replies
4
Views
80

### 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
69

### 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
}
4. ## Thread: C - Stdin Buffer

by Salem
Replies
9
Views
155

### 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.
5. ## Thread: Consolidate multiple strings to a single one

by Salem
Replies
3
Views
107

### 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...
6. ## Thread: A very SIMPLE program that is IMPOSSIBLE to create on Mac!

by Salem
Replies
6
Views
175

### 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
7. ## Thread: Valgrind complaining of unitialized variable with strstr

by Salem
Replies
2
Views
78

### 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.
8. ## Thread: A very SIMPLE program that is IMPOSSIBLE to create on Mac!

by Salem
Replies
6
Views
175

### 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...
9. ## Thread: Consolidate multiple strings to a single one

by Salem
Replies
3
Views
107

### 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;...
10. ## Thread: strcpy not overwriting (segmentation fault)

by Salem
Replies
2
Views
104

### 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...
11. ## Thread: Circular rotation pf string array

by Salem
Replies
2
Views
88

### > 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
157

### You just did.

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

by Salem
Replies
4
Views
122

### 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.
14. ## Thread: Need guidance on how to make a rectangle be printed with two characters

by Salem
Replies
6
Views
324

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

Cross-posted here -> Need guidance on how to make a rectangle - C++ Forum
15. ## 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.
16. ## Thread: Random Number Generator

by Salem
Replies
3
Views
150

### Do something like rand() % 100

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

by Salem
Replies
1
Views
104

### 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.
18. ## Thread: Function not returning date string

by Salem
Replies
2
Views
130

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

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

by Salem
Replies
14
Views
325

### 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...
20. ## 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,...
21. ## 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?
22. ## Thread: Sanitizing MySQL Query?

by Salem
Replies
5
Views
319

I'm fed up of fixing the colour eyesore that you post by default.

Also, malloc and mysql_real_escape_string...

by Salem
Replies
3
Views
285

### So what's your question? I could tell you to...

I could tell you to not use such large arrays, and to allocate it dynamically.

I could tell you to read the valgrind message, and use the --max-stackframe like it tells...

by Salem
Replies
3
Views
285

### > ==15108== at 0x419BD5: loadMap (map.c:356)...

> ==15108== at 0x419BD5: loadMap (map.c:356)
I suppose it might help to know which actual line of code this corresponds to your snippet.

> int numbers[ROOMS];
Is ROOMS some stupid large...
25. ## Thread: srand and Random number generator

by Salem
Replies
14
Views
325

### Well your generate_random and main are all mushed...

Well your generate_random and main are all mushed together.

It's

void generate_random ( int *a, int n ) {
// some code goes here
}

int main ( ) {
Results 1 to 25 of 500
Page 1 of 20 1