?
Solved

How to clear a pointer?!

Posted on 2008-10-29
7
Medium Priority
?
731 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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 and use conditional statements in the C programming language.
Suggested Courses

777 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