function

Using SWIG with pointer to function in C struct

I'm trying to write a SWIG wrapper for a C library that uses pointers to functions in its structs. I can't figure out how to handle structs that contain function pointers. A simplified example follows. test.i: /* test.i */ %module test %{ typedef struct { int (*my_func)(int); } test_struct; int add1(int n) { return n+1; } tes...

A homework about growth rate of function

Please order the function belows by growth rate n ^ 1.5 n ^ 0.5 + log n n log ^ 2 n n log ( n ^ 2 ) n log log n n ^ 2 + log n n log n n ps: Ordering by growth rate means, as n gets larger and larger, which function will eventually be higher in value than the others. ps2. I have ordered most of the functions: n , n log log n, n log n,...

Send variables to javascript(jquery) function.

Hi, I wont to be able to send a variable to a JavaScript function when I click on a link but for some reason I cant find anywhere on how to do it on the internet. Here is the function at the top of my page: <script> $(document).ready(function(){ $('[name=updateInterface]').click(function() { $("#interfaceScreen").load("modules/interfac...

What happens in assembly language when you call a method/function?

If I have a program in C++/C that (language doesn't matter much, just needed to illustrate a concept): #include <iostream> void foo() { printf("in foo"); } int main() { foo(); return 0; } What happens in the assembly? I'm not actually looking for assembly code as I haven't gotten that far in it yet, but what's the ba...

C function syntax, parameter types declared after parameter list

I'm relatively new to C. I've come across a form of function syntax I've never seen before, where the parameter types are defined after that parameter list. Can someone explain to me how it is different than the typical C function syntax? Example: int main (argc, argv) int argc; char *argv[]; { return(0); } ...

Execute JavaScript function with externally loaded link

Hi, I'll admit the title is a bit confusing but it was hard to come up with a better one. Ok, so What I have is 3 pages, first is the main page that the user loads up and the other 2 are ones that are going to be loaded into the main page with jQuery. Here is the JavaScript code on the first page: $(document).ready(function(){ $("#ma...

Finding the function caller in C.

Hey all, I'm just wondering if it is possible to get the name of the program thats running within a function? Here's an example: Say I called: ./runProgram main() { A(); } function A() { // Possible to retrieve "runProgram" if I cannot use main's argc(argv) constants?? } ...

Problem in a function actionscript

How do I add a variable that varies with the dummy variable in a loop: function resetAll(menuNum){ trace(menuNum); for (i=0; i<=7; i++){ if(menuNum != 1){ menu_all_mc.this["btn_"+i].gotoAndStop("off"); } } } this["btn_"+i] don`t work I need pass the btn name like: btn_1 and next loop btn_2 ... ...

Use Variable of a function in another function without parameters?

i like to make my database insert more dynamicly with functions. Like this: private void setValues() { string test = "foo"; string test2 = "bar"; } private void WriteToDB() { dc dcOfMyDatabase = new dc(); DBTable myTable = DbTable() { field1 = test; // values of other function field2 = test2; // values o...

Javascript: Fade in and out

Hello, i have this PHP based doc (chatbox) where you can type your message and send it. Now, i have this fade animation where a message comes in when a message is send. Looks like this: Javascript: function stateChanged1() { if (xmlHttp1.readyState==4) { document.getElementById("sent").innerHTML="Sent!"; document.writeform.message...

How to make functions with flag parameters? (C++)

How could I make a function with flags like how Windows' CreateWindow(...style | style,...), for example, a createnum function: int CreateNum(flag flags) //??? { int num = 0; if(flags == GREATER_THAN_TEN) num = 11; if(flags == EVEN && ((num % 2) == 1) num++; else if(flags == ODD && ((num % 2) == 0) ...

PHP call_user_func vs. just calling function

I'm sure there's a very easy explanation for this. What is the difference between this: function barber($type){ echo "You wanted a $type haircut, no problem\n"; } call_user_func('barber', "mushroom"); call_user_func('barber', "shave"); ... and this (and what are the benefits?): function barber($type){ echo "You wanted a $ty...

Hide console in C system() function, Win.

Hello. I am coding a C program in Dev-C++, and I need to use a couple of Windows (CMD) commands. It is easy, but when the command in the system() function is executed, the program runs the console in the execution. An example: #include <stdio.h> #include <stdlib.h> #include <windows.h> int main() { system("if not exist ...

Make a new asynchronous call inside a callback function

I would like to use the Google AJAX Feed API to fetch multiple newsfeeds and display them on a webpage. I can't use Google's FeedControl class because I want to control the way the items of the feed are displayed. That leaves me with Google's Feed class as the only option. I've got it to work with a single feed: provide a url and a c...

Confusion with the problems of inline function

In the problems of inline functions in wikipedia : http://en.wikipedia.org/wiki/Inline%5Fexpansion#Problems it says : "# A language specification may allow a program to make additional assumptions about arguments to procedures that it can no longer make after the procedure is inlined." Could somebody elaborate this point? How do you p...

Need the class of a parent function's returned element

Hello, Somewhat new to jQuery, so excuse the attempt at properly identifying things. I need an element's id to be reflected in a selector that is a couple functions deep, and I'm not quite sure how to go about doing that. $("input[type='file'][id^='pic_']").change( //I need this element's id... function() { $("."+this.id).hi...

Running javascript code with html form submit

Hey, I'm using a html form that is used to log people into my website, I am building it so it uses AJAX (jQuery) but I'm having some problems. Here is the JavaScript: function validateLoginDetails() { $('[name=loginUser]').click(function() { $("#mainWrap").css({ width:"600px", height:"200px" }); $("#interfaceScreen"...

OCaml: What is the different between `fun` and `function` keywords?

Sometimes I see code like let (alt : recognizer -> recognizer -> recognizer) = fun a b p -> union (a p) (b p) Or like: let hd = function Cons(x,xf) -> x | Nil -> raise Empty What is the difference between fun and function? ...

Binding multiple handlers to elements

Hey, I'm new to JavaScript so this is most probably going to sound really basic but here goes. My web page is made up of "modules" which I load into the page with jQuery, so that my JavaScript works with the new content that has been loaded into the page, I have been told to use callback functions. My problem is though, how do I activa...

How to call a function inside itself?

I have a function that generates a key of 4 characters that has to be unique for each time. In order to do that, the function first generates a key, and then checks a database table to see if it's in use by someone else. If it's not in use, it returns the key, else, it calls itself again, but this causes the function to do an infinite l...