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 06-11-2004, 01:34 AM   #1 (permalink)
saurabh1905
Registered User
 
Join Date: Jun 2004
Location: India
Posts: 4
saurabh1905 is on a distinguished road
C problem

How can I call a function, given its name as a string?
saurabh1905 is offline   Reply With Quote
Old 06-11-2004, 01:55 AM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
generally, the answer is "dont do that". there are very few instances where calling a function by string name is a good idea (dynamic linking and virtual functions being the exceptions). i'd love to hear your reason for doing this.

if you must do it, create an array of char *'s (the function name) and function pointers (the actual function you want called). then, just find the name that you were asked to invoke, and its associated pointer.
joe_bruin is offline   Reply With Quote
Old 06-11-2004, 02:00 AM   #3 (permalink)
saurabh1905
Registered User
 
Join Date: Jun 2004
Location: India
Posts: 4
saurabh1905 is on a distinguished road
Thanks a lot joe.
saurabh1905 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
c simple question problem with switch case if13121 Standard C, C++ 1 10-24-2004 10:43 PM
operate overloading member function in C# sureshkumar_kc MS Technologies ( ASP, VB, C#, .NET ) 2 10-15-2004 03:36 AM
For those who have Learned C from "The C Programming Lanuage" DemosthenesB Standard C, C++ 5 07-13-2003 01:22 AM
edit? anon Lounge 10 11-21-2002 04:02 PM


All times are GMT -8. The time now is 12:13 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