- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 2
- Posts with Upvotes
- 1
- Upvoting Members
- 2
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
11 Posted Topics
[code=c] #include <stdio.h> int main() { int n = 12345; int sum = 0; while (n != 0) { int c = n%10; sum += c; n /= 10; } printf("The sum is %d\n", sum); return 0; } [/code] this should work just fine
hi there, i try to map a file in memory, in linux, using mmap, so that what i write in memory will be written in the file as well. the piece of code looks like this [code=c] fd = open(argv[1], O_RDWR); if (fd == -1) { error_message(__FILE__, __LINE__, "'open' failed …
[QUOTE=Duoas;479041] [code=C] strcpy( s1, argv[ 1 ] ); strcpy( s2, argv[ 2 ] ); [/code] [/QUOTE] Please don't do that again!
really? can you? hmm... never thought about that... but from what i know, when the if clause is true the esle clause doesn't get to be tested, so it won't execute and when if cluase is false, then it will be executed the else clause. can an expression be true …
[code=c] int status; int options; ... switch (pid = fork()) { case -1: /* fork failed */ printf("forked failed\n"); exit(-1); case 0: /* child starts executing here */ execl(...); default: /* parent starts executing here */ waitpid(pid, &status, options); ... } [/code] You can then examine status, ans see how …
i think you can use a backtracking algorithm. i don't have time to write some code, but you get the idea. you will need a linked list instead of arrays, for better memory usage. every element in the list will be another list containing a sequence like those in the …
if you have a[10] a refers to the address of the first element of the array so you will have 10 * sizeof(int) bytes occupied by the array.
[QUOTE=boyz;475923]1.main() 2.{ 3. int a=0; 4. while(...) 5. { 6. int a=9; 7. } 8.} now friendz question is question is what make a of 3 global and a of line 6 local what is happend at the time of local decla.. and at the time of global decl... would …
[code=c] #include <stdio.h> int main() { int a=2, b=3, temp; printf("a: %d, b: %d\n", a, b); (temp = a) && (a = b) && (b = temp); printf("a: %d, b: %d\n", a, b); return 0; } [/code] is this what you are looking for?
maybe the man really needs to know this stuff.. [url]http://livefusion.wordpress.com/2006/08/24/c-program-without-main/[/url] i like the one with the #define, really nice :D
actualy, if the subscript is greater than the size of the array 2 things can happen: 1. the value will be storred in the next memory location, calculated by the index, so if v[10] is a vector, than v is the address of its first element, and v[i] is *(v+i) …
The End.
doublex