Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.20 seconds.

  1. > 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. ...
  2. 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...
  3. 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...
  4. 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));
    }
  5. Thread: hex increment

    by Salem
    Replies
    3
    Views
    74

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

    by Salem
    Replies
    9
    Views
    161

    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.
    fread will...
  7. 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...
  8. 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
  9. 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.
  10. 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...
  11. 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;...
  12. Replies
    2
    Views
    106

    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...
  13. Replies
    3
    Views
    112

    > 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.
  14. Replies
    2
    Views
    158

    You just did.

    You just did.
  15. Replies
    4
    Views
    123

    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.
  16. Cross-posted here -> Need guidance on how to make...

    Cross-posted here -> Need guidance on how to make a rectangle - C++ Forum
  17. I'm pretty sure all that nonsense results in...

    I'm pretty sure all that nonsense results in undefined behaviour.
  18. Replies
    3
    Views
    151

    Do something like rand() % 100

    Do something like
    rand() % 100
  19. Before the exec call, do this ...

    Before the exec call, do this


    dup2(pfd[READ], STDIN_FILENO);

    This will join the appropriate end of the pipe to the stdin of the child process.
  20. Replies
    2
    Views
    130

    Duplicate Function not returning date string...

    Duplicate
    Function not returning date string
  21. 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...
  22. 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
    Reading symbols from ./a.out...done.
    (gdb) b substr
    Breakpoint 1 at 0x4008b9: file foo.c,...
  23. 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?
  24. Replies
    5
    Views
    320

    Can you please use "copy-as-text" in your IDE, or...

    Can you please use "copy-as-text" in your IDE, or "paste-as-text" in your browser.
    I'm fed up of fixing the colour eyesore that you post by default.

    Also, malloc and mysql_real_escape_string...
  25. So what's your question? I could tell you to...

    So what's your question?

    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...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4