Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-12-2008, 10:47 PM   #1 (permalink)
itfl
Recruit
 
Join Date: Mar 2008
Posts: 1
itfl is on a distinguished road
invalid conversion error help plzzzz

hey guys, plz help with this

char data[6]="input";
int start_timer(void *fptr, void *data, int timeout);
int start_timer(void *fptr, void *data, int timeout)
{
int tid;
for( tid=0;tid<MAX_TIMERS;tid++)
{
if ( timers[tid].usedflag == FALSE)
{
timers[tid].usedflag = TRUE;
timers[tid].fptr = *fptr;
timers[tid].timeout = timeout;
timers[tid].data = data;
return tid;
}
}
return FALSE;
}
main()
{


initialize_timer();
start_timer(input,data,5);
while(1)

}

void input(char *ptr)
{
printf("data is %s",ptr);
}



am gettin an error:
" invalid conversion from 'void (*)()' to 'void*'

plz help me out
this is not the entire prog, i have jus pasted a part of it...
itfl is offline   Reply With Quote
Old 03-13-2008, 12:39 PM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 660
DJMaze is on a distinguished road
what is void?

Is it a string? noooo...
Is it an integer? noooo...
Is it a char? noooo...

It is superman!

Ehm.. Superman is not proper C code it is fiction so it should not be in your code
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 03-14-2008, 09:41 PM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Whoa, what is this supposed to be doing and what are you doing with it?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 03-17-2008, 07:32 AM   #4 (permalink)
QUantumAnenome
Code Monkey
 
Join Date: Mar 2005
Posts: 55
QUantumAnenome is on a distinguished road
Send a message via Yahoo to QUantumAnenome
Almost any pointer will convert to a void *, however a void * will not convert to another pointer type unless you use a typecast. Declaring a pointer to a function is shown below.

Code:
void *x;               // pointer to whatever
void (*fPtr)(int);   // pointer to a function of the form void f(int)

void foo(int)
{
	x = foo;		// No worries here
	fPtr = foo;	// As intended
	fPtr = x;		// Error!
}

Last edited by QUantumAnenome; 03-17-2008 at 07:33 AM. Reason: bad code tags
QUantumAnenome is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid conversion Zyko Standard C, C++ 1 06-20-2005 04:30 AM
void * conversion problems Lovecraft Standard C, C++ 6 04-28-2004 03:51 AM
invalid conversion paul Standard C, C++ 3 02-02-2004 10:58 AM


All times are GMT -8. The time now is 03:54 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting