codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

Pass a variable size value out of Filereader function for seperate manipulation


By : , Category : php

You'll need to use a callback function. Basically, a callback function is a function that runs when a piece of code has finished running. In your case, you'd submit the form via the callback function. Have a look at this article.

ReLated :

I have a char* data that I casted in order to access it like this

And that's the source of your problems. It's a contiguous memory block. Write a view facade if you need a different interface, or...

My problem is how can I pass "arr" as an argument to a function ?

The easiest way is to avoid using (terrible) low-level primitives left in the language for C compatibility.

If you don't know the size at compilation time, use an std::vector. If you do know, use std::array.

but I need to avoid multiplications for speed constraints.

Unless you have benchmark data to back that up, I am dismissing that requirement as a premature optimization.

Yes, it is possible:

#include <stdio.h>

void test(char (*foo)[6]) // "declare foo as pointer to array 6 of char" 
{
  printf("%zu
", sizeof(*foo)); // mind the asterisk
}

int main(void)
{
  char foo[6];
  test(&foo); // mind the ampersand
  return 0;
}

Compare cdecl.org ("C gibberish ↔ English") for


Another option is wrapping the array. But if you don't like referencing/dereferencing, then this solution with an addition member access probably is not what you are looking for, either:

#include <stdio.h>

typedef struct
{
  char data[6];
} char_6_array_t;

void test(char_6_array_t foo)
{
  // prints "6: abcdef"
  printf("%zu: %.*s
", sizeof(foo.data), (int) sizeof(foo.data), foo.data);
}

int main(void)
{
  char_6_array_t foo = { {"abcdef"} };

  // Depending on the ABI, this prints 6, 8, or possibly 16:
  printf("%zu
", sizeof(foo));

  test(foo);
  return 0;
}

This is an example how you can do this.

$('.mainnav').find('li').on({
    mouseenter: function() {
        var c = $(this).attr('class');
        $('#background-wrap').find('img').attr('src', 'images/' + c + '.jpg');
    },
    mouseleave: function() {
        $('#background-wrap').find('img').attr('src', 'images/bg2.jpg');
    }
});

http://jsfiddle.net/TC9SN/

In the fiddle, even though you can't see the image change. But if you use firebug you can see the source of the image changing.

Alternatively, you can have 4 images loaded in the container to begin with. Hide them all with css except for the initial one. Then when you hover the list, you can simply add/remove class for the div to set which image to show and which to hide. This way there is no loading time for all of the images when changing them. But I guess you can also pre-load all the images first

You could either define a hitArea (http://www.createjs.com/Docs/EaselJS/classes/DisplayObject.html#property_hitArea) if your image only requires one segment or if you want multiple clickeable areas on one image: Split up the image through using multiple Shapes via beginnBitmapFill (an example for bitmapFill can be found here: http://jsfiddle.net/lannymcnie/nmLhu/) and then put the listeners on the individual shapes.

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .