Solved

How to clear a pointer?!

Posted on 2008-10-29
7
725 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now