User Profile

Collapse

Profile Sidebar

Collapse
srbakshi
srbakshi
Last Activity: Mar 1 '11, 05:45 PM
Joined: Aug 14 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • srbakshi
    replied to stack and queues
    in C
    @abhinav
    Although my approach works you might want to look at hype261's answer as well since for a stack having a large number of items, my approach would be very inefficient. :)
    See more | Go to post

    Leave a comment:


  • srbakshi
    replied to stack and queues
    in C
    Hi Donbock,

    My thinking was as follows:

    We have to implement the Push and Pop functionality of a stack using the Enqueue and Dequeue functionality of a queue. Here's what I thought could be done:

    1. Push:

    Will be same as an enqueue operation on a queue.

    2. Pop:

    Dequeue n-1 (n being the total number of items in the queue) number of items from the queue and enqueue...
    See more | Go to post

    Leave a comment:


  • srbakshi
    replied to stack and queues
    in C
    I think you can implement a stack using just one queue. You can use the enqueue/dequeue functions of the queue to implement the push/pop functions of the stack.
    See more | Go to post

    Leave a comment:


  • srbakshi
    replied to program for selection sort in c language
    in C
    In line 22 you are printing the address and not the value.
    Change this:
    Code:
    printf("%d\t",&arr[i]);
    to this:
    Code:
    printf("%d\t",arr[i]);
    See more | Go to post

    Leave a comment:


  • Hello all! :D

    Sorry for the delay in replying, too much work in office. :'(

    Oralloy you were spot on with your first suggestion about opening the file in binary mode. When I was using fopen to create the file, i *was* using the "b" flag to open it in binary mode, and that was the reason why I could open it in IrfanView.

    The reason for the file not opening in Windows Photo Viewer was actually a pretty...
    See more | Go to post

    Leave a comment:


  • How to recieve a jpg from server using socket programming?

    Hi all,

    I have a small problem.

    I am trying to download a JPG image from a server using C socket programming.

    I use the following to "recv" the byte stream and store it into a file I call "test.jpg".

    Code:
    int fp = open("c:\\test.jpg", O_RDWR|O_CREAT);
    
    /* set up the socket connection */
    
    while(recvdata != 0){
       recvdata = recv(sockfd,
    ...
    See more | Go to post

  • srbakshi
    replied to mysql_real_escape_string wrapper problem!
    in C
    Right here: http://dev.mysql.com/doc/refman/5.1/...pe-string.html
    Im working on Sun Solaris and the mysql_real_esca pe_string you talked about does not work.
    So any suggestions now?
    -Sid...
    See more | Go to post

    Leave a comment:


  • weaknessforcats that was a wonderful tut. I was actually referring to the solution given by Banfa, which is nothing but a solution to the problem of not being able to "return" string.


    :O)

    @unauthorized
    Thanks a lot for telling about the alternate way of doing this although I gotta admit double pointers make me a little woozy! :p Deferring implementation until coding God-mode is acquired. :O)...
    See more | Go to post

    Leave a comment:


  • srbakshi
    started a topic mysql_real_escape_string wrapper problem!
    in C

    mysql_real_escape_string wrapper problem!

    Hey all,
    I'm stuck with the following:

    The mysql_real_esca pe_string(conn, to, from, strlen(from)) function does not return the escaped string. So how can I go about writing a wrapper for it so that it RETURNS the 'to' string which in turn helps me fill out a query in the following manner using sprintf:

    Code:
    unescaped_query = "INSERT into MYTABLE values ('%s', '%s')";
    sprintf(escaped_query, unescaped_query,
    ...
    See more | Go to post
    Last edited by Atli; May 23 '09, 06:04 AM. Reason: Cleaned up the title.

  • Thanks to you Mr.Banfa I got my code working after incorporating the above suggestions. I'm thankful to you for telling me a more efficient way of doing this.
    Thanks to Mr.JoshAH as well.

    I guess this question really boils down to the solution for returning a char array from a function. :p
    Be back with more queries as I learn.
    -Sid...
    See more | Go to post

    Leave a comment:


  • Thank you atli and Markus. That helped. :)
    -Sid
    See more | Go to post

    Leave a comment:


  • Changing the size of an array passed to a function problem!

    Hi all,

    I have the following scenario:

    Code:
    int main()
    {
       char a[] = "Hello";
       printf("Modified string: %s\n", modify_str(a));
    }
    
    char *modify_str(char *b)
    {
       /* Insert a  '+'  after every letter in the string */
       /* "Hello" becomes "H+e+l+l+o+" */
       return b;
    }
    Now my...
    See more | Go to post

  • When should special characers be escaped inside strings?

    Hi all. I picked up the following code example from the php manual:
    Code:
    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
        OR die(mysql_error());
    
    // Query
    $query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
                mysql_real_escape_string($user),
                mysql_real_escape_string($password));
    My question is, shouldn't we be escaping...
    See more | Go to post
    Last edited by Atli; May 18 '09, 07:07 PM. Reason: Moved to the PHP forum, and the title cleaned up a bit.

  • srbakshi
    replied to Query regarding optimization of my code
    in C
    Thank you Mr.Banfa for your expert comments. :O) I'll try the hash method as well just for fun.
    Thanks again,
    Sid
    :O)...
    See more | Go to post

    Leave a comment:


  • srbakshi
    started a topic Query regarding optimization of my code
    in C

    Query regarding optimization of my code

    Hi all!
    I have a txt file that has some strings in the following format:

    TAG=MyString
    Eg:
    Code:
    FRUIT=I like mangoes
    CARS=I like red cars
    .
    .
    .
    PUSHUPS=I can do a zillion non-stop
    Now what I'm doing is search the TAGs in the file and storing the corresponding string associated with the TAG in a global string (1 for every tag) Something like this:
    Code:
    #include<stdio.h>
    ...
    See more | Go to post

  • srbakshi
    replied to Query about strings and pointers
    in C
    ooooh! That's a great way of dealing with malloc. I'm glad I posted my query here. Got to learn new things.
    Thank you Mr.Donbock.
    :O)
    Sid...
    See more | Go to post

    Leave a comment:


  • srbakshi
    replied to Query about strings and pointers
    in C
    Thank you Mr.Donbock for your informative reply. :)

    I actually did not intend to alter the string. So going by your word I used the 1st approach. Thank you for letting me know how this works. The malloc'ing of extra memory was just because I was too lazy to count the number of chars in "Hello World!'. :p

    Thanks again Mr.Donbok.
    Sid...
    See more | Go to post

    Leave a comment:


  • srbakshi
    started a topic Query about strings and pointers
    in C

    Query about strings and pointers

    Hi all! I have the following code:

    Code:
    typedef struct A
    {
          char* string;
    }A;
    
    //Function prototype
    void fill_up_A(A* a);
    
    int main()
    {
          A var_A;
          fill_up_A( &var_A);
          printf("String is : %s", var_A.string);
          return 1;
    }
    
    //Function definition
    void fill_up_A(A* a)
    {
    ...
    See more | Go to post
No activity results to display
Show More
Working...