Solved

How to clear a pointer?!

Posted on 2008-10-29
7
728 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

820 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