Solved

How to clear a pointer?!

Posted on 2008-10-29
7
730 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
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.

691 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