Search:

Type: Posts; User: zalezog

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    8
    Views
    28,068

    If the format of the given string is strict ie...

    If the format of the given string is strict ie with no spaces between the number and amino-acid name, instead of making an enum, i would rather treat it as a static C-string array with each element's...
  2. That's what exactly happens. The caller gets p,...

    That's what exactly happens. The caller gets p, In my_free function , as soon as the line p-- is encountered, your pointer does not lie in the malloced region in memory, no wonder valgrind reports an...
  3. I checked with valgrind, it reports ==5414==...

    I checked with valgrind, it reports


    ==5414== LEAK SUMMARY:
    ==5414== definitely lost: 196 bytes in 2 blocks
    ==5414== indirectly lost: 0 bytes in 0 blocks
    ==5414== possibly lost: 0...
  4. Where do you free memory for the structure mem ?...

    Where do you free memory for the structure mem ? You freed nbytes but you definitely lose memory equal to the size of the structure.
  5. Replies
    24
    Views
    2,972

    Actually, since OP used %s , the hex unsigned...

    Actually, since OP used %s , the hex unsigned chars were interpreted as normal chars and written to the output stream where
    0x4D = 'M',
    0x5A = 'Z',
    0x90 = it did print if you look closely, but...
  6. Thread: File read

    by zalezog
    Replies
    7
    Views
    1,532

    fgets(input,100,stdin); ...

    fgets(input,100,stdin);

    if(strcmp(fgets(input,100,stdin),"print\n") == 0)

    Used fgets(..) twice, i hope this is pseudo-code.
  7. Replies
    6
    Views
    3,791

    and i said ?

    and i said



    ?
  8. Replies
    6
    Views
    3,791

    Given a Boolean expression, its dual is formed by...

    Given a Boolean expression, its dual is formed by replacing '+' with '.' , '.' with '+', 0 with 1 or 1 with 0.

    Given a boolean equation like x + 1 = 1, its dual is x . 0 = 0 and when you prove x +...
  9. Replies
    19
    Views
    6,951

    The question said : Constant Extra Space. Did...

    The question said : Constant Extra Space.

    Did not say you must use O(n) space.
    It did not say you cannot sort data.

    Why not use non comparison based sorting techniques?
  10. Replies
    16
    Views
    14,068

    f(x) = sin x(part of the original function), if...

    f(x) = sin x(part of the original function),
    if you are expecting results, with x in degrees, then this line may be the offending line



    *(y+i)=pow(log10 (sin ((180.0/3.141593) *...
  11. Sure it is : int data[1000] . . if(...

    Sure it is :


    int data[1000]
    .
    .
    if( data[1000] == n)
  12. Replies
    7
    Views
    4,575

    For a given word in a file, after reversing the...

    For a given word in a file, after reversing the current word, you must determine whether its reversed word exists.

    Like in your example if "desserts" is the current word , then the existence of...
  13. Replies
    3
    Views
    1,023

    If x1 is the distance from earth for DA traveling...

    If x1 is the distance from earth for DA traveling to Saturn and x2 be the distance traveled by DB, whose distance from earth is given by x2, then the distance traveled by DB from Saturn is given by :...
  14. Replies
    13
    Views
    2,472

    In the above expression , the datatype of r is...

    In the above expression , the datatype of r is size_t which rightly interprets the result as a large positive number( 0 - 1 = UINT_MAX - 1), but m is an int an implicit casting occurs and which...
  15. Replies
    3
    Views
    1,810

    If the input file contains numbers which are...

    If the input file contains numbers which are repeated, then calculating the same sequence is an overhead, why not store those numbers in a vector or an array.

    For a particular number whose...
  16. Replies
    5
    Views
    1,240

    for ( x = 0; x < sizeof(numbers) ; x++ ) Are...

    for ( x = 0; x < sizeof(numbers) ; x++ )


    Are you sure that the size allocated at compile time and sizeof(numbers) same?
    Check for yourself by adding a printf statement




    .
  17. Replies
    10
    Views
    1,919

    I think it should be : ptr = realloc(ptr,...

    I think it should be :


    ptr = realloc(ptr, (offset+1) * sizeof(*ptr));


    Haven't tested it though.
  18. Replies
    36
    Views
    9,851

    Should be unsigned int . printf("%u",...

    Should be unsigned int .


    printf("%u", UINT_MAX);
  19. Suppose you want X bytes to be allocated(the very...

    Suppose you want X bytes to be allocated(the very first time).When this piece of code is executed


    if(count==MAXMEMORY-1){ //Entire memory is available.
    printf("Entire memory is...
  20. Replies
    3
    Views
    2,046

    double QuadraticRoot1( double dA, double dB,...

    double QuadraticRoot1( double dA, double dB, double dC )
    {
    double dRoot = 0;

    .
    .
    else {
    // value is complex
    }
    return dRoot;
  21. Replies
    4
    Views
    1,432

    No, it does. it does not print prime numbers...

    No, it does.
    it does not print prime numbers because


    for(j=1;is_prime(j)==0;j++)


    the test condition is wrong. 0 means it is NOT prime. So it does not get executed at all.If the inner for...
  22. Replies
    2
    Views
    1,013

    Your /*outcome stores the result So at the...

    Your

    /*outcome stores the result
    So at the end of void CheckWinner(int PlayerChoice) function,
    check for
    */
    if (outcome == Win)
    user++;
    else if (outcome == Lose)
    computer++;
  23. Replies
    14
    Views
    1,732

    Are you sure 'a' is supposed to be an int ? ...

    Are you sure 'a' is supposed to be an int ?


    I changed it to double(and 8039.0 / 25000) and it ran without any compile-time or runtime errors.
  24. Replies
    5
    Views
    2,586

    because of while(tab[poz] < x && tab[poz]) ...

    because of


    while(tab[poz] < x && tab[poz])


    0 will be the smallest number going by your non-negative number approach.After inserting 0 at it right place the algorithm fails to find poz...
  25. Replies
    12
    Views
    1,984

    Let's say you make a swap function which looks...

    Let's say you make a swap function which looks something like this:


    void swap(int idarr[], int index1, int index2, double balance[]) {
    int temp;
    temp = idarr[index1];
    idarr[index1] =...
Results 1 to 25 of 48
Page 1 of 2 1 2