Search:

Type: Posts; User: noodles

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Thread: Memory Leaks?

    by noodles
    Replies
    3
    Views
    1,702

    You're allocating memory (using new) in remove(),...

    You're allocating memory (using new) in remove(), but not deleteing it anywhere. That's a memory leak.
  2. Thread: Memory Leaks?

    by noodles
    Replies
    3
    Views
    1,702

    You're returning the vector by value. There's no...

    You're returning the vector by value. There's no problem in that since it's being copied back in the calling function.
  3. Replies
    5
    Views
    908

    If you want to print "True" if the first element...

    If you want to print "True" if the first element matches, put a break after the printf ("True.\n\n"); (within proper braces, of course).

    It seems more likely that you want to print "True" when...
  4. Replies
    5
    Views
    908

    (Looks more like C than C++) Your third for...

    (Looks more like C than C++)

    Your third for loop contains the assignment operator, and not the comparison operator. You're assigning the elements of setB to the elements of setA and then using the...
  5. Replies
    11
    Views
    1,361

    It's most probably not a bug. You must be...

    It's most probably not a bug.

    You must be relying on dangling pointers, uninitialized variables, or something like that somewhere.

    Go through your code and make sure that you're not doing...
  6. Replies
    18
    Views
    1,723

    It shouldn't happen. Try posting some code so...

    It shouldn't happen. Try posting some code so that we can have a look.
  7. Replies
    3
    Views
    977

    For printing, using only setprecision is not...

    For printing, using only setprecision is not enough:

    double a = 50.0 / 3.0;
    cout << setprecision(3);
    cout << a << endl;prints 16.7.

    You'll need to use the "fixed" manipulator...
  8. Replies
    12
    Views
    1,290

    Do you need something like this? int...

    Do you need something like this?

    int NumPrompts;
    cout << "Please enter the number of prompts you desire: ";
    cin >> NumPrompts;

    int i=0;
    while (i++ < NumPrompts)
    {
    ...
  9. Everything works fine for me (after adding a few...

    Everything works fine for me (after adding a few missing semicolons). Did you try re-compiling?
  10. Replies
    7
    Views
    3,464

    It is, but I meant that there isn't any portable...

    It is, but I meant that there isn't any portable way for ALL the types, including the signed ones, as the OP wanted.
  11. Replies
    7
    Views
    3,464

    For integral types, see the macros defined in...

    For integral types, see the macros defined in <limits.h>
    e.g. 'INT_MAX', 'INT_MIN', etc.

    For real number types, see the macros in <float.h>,
    e.g. 'FLT_MIN', 'FLT_MAX', etc.

    That's the ONLY...
  12. Replies
    3
    Views
    1,094

    >from what I know, ++(postfix) has higher...

    >from what I know, ++(postfix) has higher precedence than *, why I do not get *p1++=300?
    Since that is the postincrement operator, it performs the increment on the address AFTER the expression has...
  13. Thread: seg fault

    by noodles
    Replies
    3
    Views
    1,156

    Replace that code with: printf("The word %s...

    Replace that code with:

    printf("The word %s backward is ", word);
    for (i = strlen(word)-1; i >= 0; i--)
    printf("%c", word[i]);
    printf("\n");
  14. Replies
    3
    Views
    1,079

    There's pow...

    There's pow.
  15. Replies
    6
    Views
    1,216

    I think you mean "by value".

    I think you mean "by value".
  16. Replies
    6
    Views
    1,216

    You cannot change the base address of an array,...

    You cannot change the base address of an array, if that's what you're trying to do. Also, the array "changed_data" will no longer be accessible after the end of the function call. Try updating values...
  17. Replies
    3
    Views
    4,020

    Hope the following code helps: for (i=0;...

    Hope the following code helps:


    for (i=0; i<MAX; i++)
    {
    for (j=0; j<MAX; j++)
    my_arraystr[i][j] = my_array[i][j]+'A';
    my_arraystr[i][j] = '\0';
    }
  18. Thread: problem in C

    by noodles
    Replies
    4
    Views
    1,595

    It's good that you showed us your attempt. ...

    It's good that you showed us your attempt.

    Here are some suggestions for improving your code:
    1. Use meaningful variable names.
    2. Understand the difference between == (a comparison operator)...
  19. Replies
    1
    Views
    2,555

    You aren't reading the data properly into an...

    You aren't reading the data properly into an array. I've changed the code to the following and it works (hopefully :) ):


    /*My comments are in red*/
    #include <stdio.h>
    #include <stdlib.h>...
  20. Replies
    10
    Views
    1,140

    Try this: #include int...

    Try this:

    #include<stdio.h>
    int home,work;main(){for(home+=49; home<=53; home++){for(work=49;work<=home;work++)putchar(home);
    puts("");}for (home-=2; home>=49; home--){for (work=49; work<=home;...
  21. Replies
    11
    Views
    2,096

    Go through the following code. If you have any...

    Go through the following code. If you have any questions, please don't hesitate to ask!

    #include <stdio.h>
    #include <ctype.h>
    int main()
    {
    int num;
    printf("Please enter a digit from 0...
  22. Replies
    13
    Views
    3,311

    Poll: I tried using RSS a few times, but soon realized...

    I tried using RSS a few times, but soon realized that it is USELESS.
  23. Replies
    8
    Views
    2,078

    It's printing 0 infinitely because you're not...

    It's printing 0 infinitely because you're not passing the incremented value to test in the recursive call.

    To make it work use

    test(++count); /*pre-increment*/

    instead of

    test(count++);...
  24. No, printf() uses %f for floats and doubles.

    No, printf() uses %f for floats and doubles.
  25. Replies
    5
    Views
    10,776

    > c = 170; /* generates compiler overflow...

    > c = 170; /* generates compiler overflow warning */

    It's not an overflow: you're assigning an out-of-range value.

    You're assigning a value in the range 0..UCHAR_MAX to a variable that can...
Results 1 to 25 of 75
Page 1 of 3 1 2 3