An array of strings as function parameter in loop fails

Hallo,

I have a weird problem here and I hope someone can help me find the cause.

I have a function where I said an array of strings (string_list). I pass the array to a function that does modifactions to the table. I am addressing Walker the array of strings to an index of all the values are stored correctly. When I loop through the array by incrementing the index automatically only the last index value are saved in all positions.

Why is this? Or what I am doing wrong?

It is the passage to another function, an array of strings
int calling_function
{
char * string_list [MAX_PATHNAME_LEN]; //< store="" strings="" in="">
function_called (string_list); passing a pointer to an array of string
return 0;
}

This is the function receives a reference to an array of strings to store data
int function_called (char * output_list [])
{
int i = 0; counter variable
/ * This works and good values are stored in output_list * /.
output_list [0] = '02 ";
output_list [1] = '12 ';
output_list [2] = "22";
output_list [3] = "32";
output_list [4] = '42 ';
output_list [5] = "52";
output_list [6] = '622 ';
output_list [7] = "72".

/ * This does not work and will store '31' in all places of the matrix * /.
< 32="">
{
< %d »,="" i) ;="" incrémenter="" la="" valeur="">< br=""> output_list [i] = sample; < br=""> i = i ++ ; < br=""> < br="" >="">

output_list [0] = '02 "; < br=""> output_list [1] = '12 ';< br="" >="">

Thanks!

Hi,.

When you do

output_list [i] = sample;

all of the members of the array have the same value: sample-a char pointer. You are modifying the afterwards glad of sample purpose the previous values still point to sample.

If you assign values to each array member like:

you assign different values: a pointer to a string containing "02", pointing to a string contaning "12",...

If you want to assign values in a loop you need to allocate memory for each string (output_list [i]) and copy the content of sample in them.

Does this make sense to you?

Constantin

Tags: NI Software

Similar Questions

  • Array of strings for DNS in workflow Clone VM

    The VM Clone with single NIC workflow requires an array of strings as a parameter inut DNS servers. I'm not sure how to pass an array to this parameter. In c#, I have:

    String [] dnsArray = {"10.130.132.109", "10.130.132.108"};

    dns1Attribute.name = pmArray [18] .name;

    dns1Attribute.type = pmArray [18] game;

    dns1Attribute.value = dnsArray;

    attributeArray [18] = dns1Attribute;

    However, c# generates an error 'cannot implicitly convert type() Sting in string' for line 4. I tried passing a single string as attribute value, but it doesn't seem to work either - no value is entered in the workflow when it is running.

    Anyone have any ideas on that. An example of Java would be nice too - I am flexible.

    Thank you!

    Hi geno5150,

    here how to create a table to pass:

    var monTableau = new Array();

    MyArray.push ("10,20,30,40");

    MyArray.push ("192.168.100.254");

    For this move as an attribute:

    var AttrArray = newArray();

    var Attr = new Attribute();

    Attr.Name = '< ParameterName > '.

    Attr.Value = myArray;

    Attr.Type = "Array";

    AttrArray.push (Attr);

    push the other attributes & run the workflow

    That's all

    -

  • Return an array of strings of call library function node

    Hello

    I'm having a few problems getting the following work.

    I have a camera from a manufacturer that came with its own .dll and header files. I'm calling the LabVIEW .dll file (2011). In total, there are about 50 functions, and there is a rest that I can't go to work (probably because I understand enough about the topic to interface with an external code).

    The description of .dll is delivered with the following text:

    #define length

    #define MAX_CONFIGURATIONS

    Prototype: int ConfigListGet (char (& sConfigurations) [MAX_CONFIGURATIONS] [length]);

    and the header file with:

    extern "C" __declspec (dllexport) int RepRateConfigurationListGet (char (& sConfigurations) [MAX_CONFIGURATIONS] [length]);

    The function should return an array of strings to the list of configurations.

    The problem I have is that I can not understand how to return the array of strings for the node of the library function call to LabVIEW. I looked a little on the web and the examples in LabVIEW and I can't find anything specific to return an array of strings in this way, so if anyone can point me in the right direction I would really appreciate it.

    Also, if I click with the right button on the node library function call and click on "File Create.c", I would be able to create the prototype of function even that above? I tried this but no luck. Was the closest I came:

    int32_t RepRateConfigurationListGet (char sConfigurations [], uint8_t MAX_CONFIGURATIONS, uint8_t MAX_LEN);

    Thank you very much in advance for any help!

    D

    Hello!

    I tried once using an array of U8, converting it to a string and then split into an array.

    Here is my old piece of code (the split part can be cleaner ;=))

    Kind regards

    Marco

  • How do the function of table 1 d search case-insensitive for the array of strings

    How do the function of table 1 d search case-insensitive for the array of strings

    Hi Karine,.

    convert the two (table and search for the string) to lowercase before using this feature...

  • CSXSInterface: Call to jsx-function with a string xml as parameter?

    Hello

    for me CSXSInterface worked very well so far with all the settings and the SyncResults.

    Now, I do a few operations xml with actionscript 3 and photoshop scripts. I am able to return an XML from a function javascript to actionscript3 and do all kinds of operations with it. Somehow, I can't call a function with the string xml as parameter jsx? Does anyone have a solution for this?

    Here is what I tried:

    var xmlStr:String = _myXml.toXMLString(); // I tried _myXml.toString() too but it didnt work either ;-(
    CSXSInterface.instance.evalScript("xmlFunction", xmlStr);
    
    

    Thanks in advance!

    Not for me it isn't...

    I use Flash Builder (with Extension Builder added on) too, and I don't remember having seen a mistake HostObject of any kind. Import you the classes necessary?

    Substances

  • "The String to Byte Array" and its operations on-site (memory) of twins "Byte Array to string"? (or if they incur sentence of copy/memory operation?)

    I can't deduct the answer to this question (topic/post title) of the help of LabVIEW on the functions.

    Intuitively, it seems that the two representations of data are equal to the memory and so goes between the two should essentially be a no-op when the code is compiled... but is it? (assuming that the length of the array of strings/remains constant, can I go back repeatedly without performance?)

    As a string of LabVIEW is a handful and any other type of data except tables aren't a handful; that implies to me that a string = U8-table-grip handle and so a string into an array of U8-could be a memory or inefficient operation since no conversion actually take place?

    The reason I ask, is that when you work with for example TCP Read or read VISA, 'data' reading is always a string, but according to what you are doing, this string is often more efficiently processed/interpreted if converted to an array of U8 and I just want to know if (memory and CPU point of view) I can move freely between the chain and U8 array and return depending on what format is most appropriate to a point?

    (Also, I'm at this stage fairly certain that the "array of strings of bytes" is cleaner AND more efficient than a type-cast to an array of U8 strin... but I could be wrong.)

    I did some tests on this just now, and my conclusion is that it is completely in place. The local users group had a coding challenge when this became relevant to my solution.

  • by passing the array of strings of Teststand to LV dll

    Hello

    I wonder, why is it not possible to pass an array of strings 1 d of TestStand to a dll, which is compiled with LabView. By the way the PropertyObject works very well, but as parameter category "Array of Strings" exist in the call dll TestStand pane, it should be possible to pass an array directly. I get an empty dialog box, where I try to view the contents of the array passed directly.

    Why it does not work?


  • String array to strings

    Hi everyone, thank you for your time.

    I recorded in a file of data like this:

    name address telephone e-mail, etc.

    Each field is separated by a tab (\t) delimiter.

    I have read each line of the file with the text file reading and read audit function lines, and then use the index string array, the result is: each while the iteration I can get the full range of text (String), I want to convert this string with fields of tab separated in an array of strings.

    Example:

    input string (name address phone email)

    Output of the elements of the string array: name

    address

    Phone

    E-mail

    Thank you all, I would appreciate any help.

    Get a constant table and create a string array, then you can change your output data type.

  • .csv in an array of strings

    Hello

    This is probably a simple problem, but I have a CSV with string values in a column with numbers in another.  For example:

    Volume 6

    Diameter, 5

    But much more of a file.

    I would like to be able to read the first column and reach a just the string array.  I tried to use text file in the spreadsheet string to array in table of Index functions, but I can't seem to get the array of strings to work, as happens with 0 for any text only.

    If someone can point me in the right direction it would be greatly appreciated.

    Thank you!!

    Transferred to the LAVA.  I posted a response there.

  • string to array OR array to string

    Hey all,.

    I'm stuck and the positions that I have sought do not seem to answer my question...

    I have several tables 1 d that I'm running into a function table build and try to put several tables of channels before that data in a file, but I can't get the strings in an array in order to put them in the table of construction (which I usually do) or get the tables 1 d to a string and format correctly (do not know) so that each array of strings fill a column like this:

    1 1 left stretched left injured injured Data1 Data2, etc...

    1 2 stretched left wounded left injured Data1 Data2, etc...

    1 3 left stretched left injured injured Data1 Data2, etc...

    I believe I have the functionality to low, just do what I have in a document, it is where I need help! I've attached a .jpg of a part of the code file to give context.

    Thank you!

    Tyler

    Try something like this, perhaps?

  • DLL of LabVIEW with arrays of strings in c ++

    I'm looking to use labview to retrieve a list of gas to a txt file and then transfer this list to gas in a C++ program.

    I thought it would be easier to just list the gas transfer a string array of the DLLs in labview to my C++ program.  However, I am not able to output the list of gas using tables; I am only able to output the pointer, not the chain that makes reference to the needle.  Of course, I have a syntactic problem with my method of output.

    I have no problem out of the list of gas via a simple string.  However, the approach of single string requires multiple calls to the relevant dll.

    My code is based on the labview dll for C++ routines example titled call of Labview DLL in Visual C++ this Passes table manages in reference (http://zone.ni.com/devzone/cda/epd/p/id/1518).

    I am sure that what I'm trying to make is simple enough for an experienced programmer to Labview.  However, my labview, C/C++ and experience is limited.

    Thank you in advance for your help.

    My labview and C code is found in the attached zip file.  However, the basic C code and output resulting are:

    // Call DLL.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Array_Multiply.h" #include  #include  #include  #include  #include  using namespace std; int main(int argc, char* argv[]) { TD1Hdl handle_var3; long temp; char stringout[25]; temp=25; handle_var3 = (TD1**)DSNewHandle(sizeof(TD1)); // initialize sizes (*handle_var3)->dimSize = 1; // // Gasstring is a function that outputs a Labview array of strings. // However, I can't make this work. All I am doing is outputting // memory addresses. // Gasstring(&handle_var3); cout << "\n gasstring " << *handle_var3; cout << "\n gasstring " << handle_var3; cout << "\n gasstring " << (*handle_var3)->String[0]; //cout << "\n gasstring " << (*handle_var4)->Numeric[0]); // // Gasstring3 is just a single string. There are no issues outputting // this string. // Gasstring3(stringout,temp); cout << "\n gasstring3 " << stringout; cout << " \n enter in number "; cin >> temp ; return 0; }
    

    The output of my source code is:

    I think I understood something :-)

    cost < "\n="" gasstring ="" "=""> < lstrbuf(*(*handle_var3)-=""> String [0]);

    There are some macros useful for LStrHandles in "extcode.h", LStrBuf is one of them.

    It seems that there are no problems with memory management, you did it right.

  • text file convert array of strings

    I tried to convert the text into an array of strings. But this is not successful.

    text file:

    SD, 1,2,3,4

    GD, 3,4,5,6

    I use the string of worksheet to the Array function, but all THE characters became zero.

    my result:

    0,1,2,3,4

    0,3,4,5,6

    Hi Hieu,

    try this way:

    When you want an array of strings that you will need to provide the constant corresponding to the lower left entry of the "chain of worksheet to the table..."

  • Can I make a class as a function parameter type?

    Thus, AS2, I had a function that would create a different movieclips based on variables, that I went in (because attachMovie() took the name of the movieclip as a string - for example attachMovie("man",...) or attachMovie ('car'...)).

    In AS3, it did more correctly now, with a new var = Man() mc or new Car().

    Is there a way for me to pass the type of class (man or car) as a function parameter to a function:

    for example

    public void MakeMovieClip(classType:<something>):MovieClip {}
    return new classType();
    }

    or do I have to do basically a block giant switch/case that switches from channels (which is what I currently do)?


    Thank you

    --
    Ken

    If you have a library item with the name of the man class, use the following code to add a movieclip Man to the scene.

    Learn more about this here.

  • Array of strings 1 d out of MathScript node

    I use arrays of cells inside a MathScript node and want to display an array of strings D 1.  I can't get output with this data type by selecting a column of string elements.  He seems to treat the strings as arrays of characters that are extremely difficult to work with.

    I've seen references 2008 who say that MathScript nodes cannot not out of arrays of strings,

    Is this always true?  Is there an example of how to get a string or some kind of workaround?

    My boss came up with a way to do it, as shown in the attached VI.

  • An array of strings of compensation fileglobal

    I have an array of strings to dimension fileglobal 2. How we it clear whenever the sequence is called, use a loop for? It used to not be a problem, but now seems to have old data in it all the time.

    Thank you

    JVH

    You can get rid of an expression:

    GetArrayBounds (Locals.Array, Locals.OriginalLowerBounds, Locals.OriginalUpperBounds),
    SetArrayBounds (Locals.Array, "[0]", "[]"), / / make the table empty to clear it.
    SetArrayBounds (Locals.Array, Locals.OriginalLowerBounds, Locals.OriginalUpperBounds) / / restore the picture to its original size

    Hope this helps,

    -Doug

Maybe you are looking for

  • COMPAQ MINI 110 c: bios password

    I have a HP Compaq Mini 110 c with a BIOS password that prevent the operating system from loading.   I tried to unplug the battery CMOS and power battery etc. with no joy, the rest password again. System hault code is: CNU93544LV If anyone can genera

  • brightness key does not work after waking fast

    Hello My brightness function key of function perfectly, but not until I put my VAIO and sleep on her back. But I tried to restart my machine, and everything is back to normal. I have day all my drivers to the latest version through Windows Update and

  • can I open an ActiveX object in word if labview is not installed?

    can I open an ActiveX object in word if labview is not installed? I want to export a LabView CWGraph3D to Word. In fact, it works pretty well in my computer but when I try to open the word file on a computer that does not have intalled of LabView, si

  • Problem with setting window of acquisition on 1429 PCIe capture card

    Hi all Recently, I am using the Basler A504k camera with card PCIe-1429 of goodwill for the acquisition of images at high speed. I found problems with setting the acquisition window in the capture card using Measurement & Automation Explorer. 1. for

  • How to set up printing wireless of my lide 120 to a brother hl-3170cdw

    Seems like scanners are the poor relative in the community, I do not see any place to ask this question other than "General Discussion." To expand on my subject line... nothing ignite communication between my Windows laptop 8.1 and my printer Brother