Problem with my libcurl attempt

This is a discussion on Problem with my libcurl attempt within the C Programming forums, part of the General Programming Boards category; I have been trying to make a little function that prints out the result of a libcurl thingy without alot ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    114

    Problem with my libcurl attempt

    I have been trying to make a little function that prints out the result of a libcurl thingy without alot of luck. Here is my little function (the function's prototype has to be exactly like that to work with the library, I just don't think my actual code in the function is right at all)

    Code:
    size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
    {
       int i;
    
       for (i = 0; i < size; i++)
         printf("%c",buffer[i]);
    }
    Here is the error I'm getting. ( line 30 is the "printf("%c",buffer[i]);" one)

    "test.c: In function `write_data':
    test.c:30: warning: dereferencing `void *' pointer
    test.c:30: error: invalid use of void expression"

    Thanks

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Well you need
    char *cbuff = buffer;

    Then index cbuff instead.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    114
    Quote Originally Posted by Salem
    Well you need
    char *cbuff = buffer;

    Then index cbuff instead.
    GREAT cheers, works fine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21