Solved

How to clear a pointer?!

Posted on 2008-10-29
7
727 Views
Last Modified: 2012-05-05
Hello group,

I'm using a callback function as cb1 (in snippet), pointer  s  is pointing to a new field of a csv file per iteration. The problem is that part of  previous data is always gets printed in next iterations.

How can I refersh it?

Thanks.

void cb1 (void *s, size_t len, void *data)
{
  printf("\n%s\n", s);
 
}
 
main()
{
   //cb1 is called during a loop
}

Open in new window

0
Comment
Question by:akohan
  • 4
  • 2
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 22838533
How are you calling cb1, and how are you pointing  s to a new field of a csv?
Is the string null terminated?
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22838531
printf("\n%s\n", (char*)s);
0
 

Author Comment

by:akohan
ID: 22838542


Hello!

Sure. I'm calling it as posted in snippet.

Thanks.




  while ((bytes_read=fread(buf, 1, 1024, fp)) > 0 )
  {
    csv_parse(&p, buf, bytes_read, cb1, cb2, 0);  //cb1 is calledback here
  }

Open in new window

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 16

Expert Comment

by:sh0e
ID: 22838587

printf(\n%.*s\n, len, buffer);

Open in new window

0
 
LVL 16

Expert Comment

by:sh0e
ID: 22838588
Typo
printf("\n%.*s\n", len, buffer);

Open in new window

0
 
LVL 16

Accepted Solution

by:
sh0e earned 250 total points
ID: 22838597
Very sorry.  This is the right one.
printf("\n%.*s\n", len, s);

Open in new window

0
 

Author Comment

by:akohan
ID: 22838608


Thank you so much!

Regards,
ak
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question