String.Contains)

Hello!

Im trying to do a search, RIM SDK is not String.contains ().

I need to do something like this:

I have a list with several names like Jonh Man, sesame Road, Mary Jane...

The user input: ROAD = userInput

I return all words with the road, such as:

Sesame road myWord [0]

Long road myWord [1]

Road test...

St. road...

How do I compare with my words of vector user input?

If I contains, I'd do something like that...

{if (userInput.Contains (myworld [i]))}

output...

}

THX...

Use string.indexOf ("word", 0)... If it returns 0 > then you can add vector myWord otherwise not...

Tags: BlackBerry Developers

Similar Questions

  • How to convert the Ascii string containing hex to hex string info?

    Dear all,

    I am busy doing a control/reading program for pumps of ISCO.

    Right now I'm in trouble with to send orders for PUMPS in HEXADECIMAL. When I use a CONTROL to the STRING in HEX display, everything works fine (when I manually write down the command in the control of the chain).

    Exist it a couple of pieces order: string Destination, length, ordering, Checksum. I'm doing a sup - screw that automatically calculates the checksum (modulo 256) and adds it to the string. Everything is going well: first of all, I shared the ascii bytes command and I calculate the checksum and add as ASCII HEXADECIMAL value to the chain of command. Also a CR (= 0d) is added. Now the whole string must be converted to hex. The string contains the right nummers HEX, but they are in ASCII format. Here was I feel worth it, I don't know how to do it!

    So to summarize:

    I have an ascii string that contains the values HEX (for example 315230303652454D4F544531420D) and it must be converted to a HEX string (for instance 3152 3030 3652 454 4531 420 4F54) for the pump of the ISCO can understand the command.

    The VI is attached.

    Thank you in advance,

    Bio

    Bio,.

    This should do what you want.

  • Is there a way to parse a string containing % (percentage symbols) using the function 'analysis of the chain?

    I am communication in series with a mirror device and the syntax of the input string contains this text: "% hr ="

    I was not able to find a way to say to the function that the percentage here is not a format specifier. Is it possible, or should I just try to use a different function?

    Thank you.

    Use %% in your format string for what he knows to use the percent literally.  So % RH = %f

    EDIT: Darin has one here in front of me.  It seems to be-% and % both work.

  • Check that a string contains data only numbers

    Hello

    I'm trying to find an elegant way to test an input string "serial number" format A00000000 (where A can be any letter and 0 can be a number any).  My first thought was to check the following features:

    (1) total string length = 9.

    (2) using the "Decimal String to the Number.vi", result = 0 (which indicates that the string contains no numbers).

    (3) using the 'Decimal string to Number.vi' with an offset of 1, the result is a number.

    Unfortunately, that does not differentiate between the following strings:

    A00005123 valid

    Invalid A5123

    Invalid A5123B123

    Invalid A005123BC

    All the world is this recently?  Is there a way to analyze non-specific chips (for example separating the groups of letters, numbers or other?)  Is there a complete way to do this without breaking the chain in 9 individual items and do a comparison of 26 item for the letter and 10 element for each number comparisons?

    Thank you

    Sean

    You can use a regular expression to match the pattern.

  • Order findstr/l/s/m print the file names of all the files in the directories and subdirectories despite any string contained

    Hello

    I'm looking for a file via the findstr command. After that I opened the command as Administrator window, I get:

    Findstr/l/s/m 'a string containing the words. " *

    Then, the command window displays all the files in the directory and its subdirectories. I think that I see which file is searched for the chain in real time.

    I expected to see only the name of the file/s if the string was found in it.

    What I am doing wrong? or why is this malcfunctionaning?

    I got directions for ordering findstr here: https://technet.microsoft.com/en-us/library/bb490907.aspx

    Thank you

    I think you want the /c parameter instead a / l.  As written, your search string is interpreted as a list of strings: 'a', 'string', 'with' and 'words '.  Any file that contains an 'a' will be a return match.  The parameter/l keeps your strings to be interpreted as regular expressions.

    If you need exactly match to the entire chain, type:

    Findstr /s/m/c: "a string containing the words." *

    Under the direction of add: It is not clear, but you can have several settings/c , to search for more than one exact string at a time.  For example:

    / s/m/c: 'a string' findstr / c: "a Word." *

    Research is 'a string' or 'a word' exactly.

  • want to use regexp_replace in pl/sql to replace a string containing repeat them consecutive to a words

    Hi Experts,

    I want to use regexp_replace in pl/sql to convert a string containing consecutive repeat words have only one.

    for example: "is my name and and I was waiting for waiting for what it" should be replaced by "is my name and I was waiting for it."

    Thanks in advance

    Gordon

    A slight change '(\w+\S\W)\1+' )

    Concerning

    Etbin

  • Test whether the string contains the only slash the other way around?

    Hello

    How do you do that?

    I need to check if

    (a) the string contains two consecutive backslashes

    (b), if not, check if there is at least an oblique bar opposite

    If (test.) IndexOf("\\") > = 0) seems to knock on a string that is 'ss\\ss', but I have a feeling that is incorrect. I think it's really just test for 1 backslash.

    AS3 and don't let you do if (test.indexOf("\") > = 0), as the single backslash escapes the rest of your code.

    It is to test for the existence of a or two backslashes in the ID3 tags, as some editors use as a delimiter for multiple tags within the category of a tag for example kind: rock\\pop, or rock\pop

    Thanks for taking a peek.

    {if(s.IndexOf("\\\")>-1})

    There are two or more backslashes consecutive

    } else {if(s.indexOf("\\")>-1)

    There is that a single backslash

    }

  • Selection of rows where column string contains special characters.

    Hey there,

    Im trying to select rows based on a column containing a bar slash.

    I tried

    where substr (col1, INSTR(col1,'/'), INSTR(col1,'/') + 1)

    but no luck, is there a special way to treat this?

    Thanks in advance,
    Date of birth
    instr (str, '/') > 0
    

    as in

    SQL> with test
      2  as
      3  (select 'this first string contains / a slash' str from dual union all
      4   select 'this second string contains / a slash' str from dual union all
      5   select 'this third does not' str from dual
      6  )
      7  select *
      8    from test
      9   where instr (str, '/') > 0
     10  /
    
    STR
    -------------------------------------
    this first string contains / a slash
    this second string contains / a slash
    
  • Is there a way to differentiate the string containing the characters and numbers?

    Hello, I created an application to read data from a serial port device. The problem is that the device, at startup, displays a block of text that contain characters describing the device. Shortly after, he displays a command prompt "command:" it's when I want my VI to enter the command to start to take action.

    I was looking at the VISA waiting on the event and looks that could be used to wait for the output device, only a "Serial character", but there is no distinction between the letters and numbers that I can tell.

    If the device is out of numbers in the reading string, of course, no need to enter the command to start to take action once again, which will probably only confuse the device. In this case, I want my VI to continue taking measures with VISA Read.

    The reason is that when I run the application, the device may have already been turned on. Send this command to the device using VISA Write is not necessary at this time.

    Any advice would be appreciated. Thank you.

    This makes it much easier.  In this case, this will do the trick.  You will notice that the bottom of the case does not match even if it has valid values inside.  The only thing that will match if the entire string is of the form XX. XXXX. Incidentally, since we are only matching numbers now, you can remove the "ignore case" Boolean as there is more important.

  • Determine if a string contains an expression of certain

    Hi all

    I feel that there should be a simple way to do this, but I was not able to understand after browsing these forums, the help of LV and Google.

    I just want to get in a string and returns true if it is false if is not to determine if it contains a certain expression. I understand there are regular expression screw, as model of matching and Match Regex, but those who return substrings; I want just a Boolean value returned. I could use the VI regular expression corresponds to analyze output strings to determine if it finds a match and returns a Boolean value from there, but I feel like there is a way better and simpler I forget.

    In the subpalette of 'additional string functions' I see there first Match string and string of true/false game, but using the first Match string seems like it would complicate what I try to do, and I don't yet know what game true/false String; detailed help is always confusing.

    Thanks for any help!

    There are simple ways. Read the help associated with search string functions! Each of them returns the offset of the found string. It is - 1 if it is not found. A simple function to Less Than Zero can be connected to this to return a Boolean value. Another way is to compare the substring returned by the function of empty string.

  • Check if a string contains "text" in a box, and only if it does not, add it to the chain.

    I have some comboboxes. I want a text field to add a channel to itself, that contains the text selected in each combobox. I got it with this:

    var a = this.getField ("CoBi_text");

    for (i = 1; i < 16; i ++) {}

    var t = (this.getField("CoB_"+i).valueAsString);

    Si (t ! = « ») {}

    a.Value += t + ',';   }   }

    But what adds text even though I select the same option in any of the combobox control. How can I include a conditional don't skip the increment if "the text is already in the string?  I tried this:

    If ((t! = «») & & (a.value.indexOf ("t") < 0)) {}

    a.Value += t + ',' ;}

    But it causes the chain add the text first, don't increment not any text more after that.

    PS. This text field will be hidden and later used on another condition (if it contains 'a specific text'), some other triggering actions.
    So the ',' (comma) is probably not necessary, but I think that it should not be in the way of a proper search indexOf (right?)

    Thank you.

    eHRM, nevermind. I got it.

    the "t" inside indexOf should not "s...".

    var a = this.getField ("CoBi_text");

    for (i = 1; i<16;i++)>

    var t = (this.getField("CoB_"+i).valueAsString);

    If ((t! = «») & (a.value.indexOf (t))<0) )="">

    a.Value += t + ',' ;}

    Now, he adds "text", but not more than once for each different text on each drop-down list.

    There is always the question of the modification of a selected item in a combobox control, how do I remove the old text from the text box but I think than any forced recalculation should be enough.

    Thank you for taking the time to respond and for the link!

  • check if a string contains only some characters

    I'm working on a java program that converts the Roman numbers. The user enters a string, and I need to check to make sure that it contains MDCLXVI and if he doesn't I will get them the input again string. I thought I'd do a while loop but I'm not sure if it's the smart way to make or the syntax to perform the check.

    Here was a thought on the control with a while loop, but I've never used it before and maybe build evil.
    while (!Pattern.matches("MDCLXVI", firstRoman))
            {
            System.out.print("Not a valid Roman Number please try again");
            firstRoman = firstRoman.toUpperCase();
            }
    My Code is as follows:
    // Ask for user to input firstRoman Number
            System.out.print("Enter your first Roman Number:");
            // add the Roman Number to the String variable
            firstRoman = keyboard.nextLine();
            firstRoman = firstRoman.toUpperCase();
    Once they enter in the it, I want to check to make sure that it has characters MDCLXVI and if it contains any other characters then I will provide a new object Scanner keyboard to try again and if it fails again, it will go to the option to try again until they put in a string that contains only the characters above. I don't know where to go here to get the while loop has worked. New to Java and I got my program work properly when I put good known numbers of novel, but I want to take incorrect entries.

    Any help would be appreciated.

    Thank you
    Wally

    I put the code for my main program and my class below just in case. I have already met the requirements of the teacher if the project is done, I'm just trying to improve.
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package myname.project.pkg6;
    
    import java.util.Scanner;
    import java.util.regex.Pattern;
    
    /**
     *
     * @author wsteadma
     */
    public class mynameProject6 {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            
            // Used for testing
            String firstRoman;
            String secondRoman;
            
            
            Scanner keyboard = new Scanner(System.in);
    
            
            // Ask for user to input firstRoman Number
            System.out.print("Enter your first Roman Number:");
            // add the Roman Number to the String variable
            firstRoman = keyboard.nextLine();
            firstRoman = firstRoman.toUpperCase();
            
                  
            // Ask for user to input secondRoman Number
            System.out.print("Enter your second Roman Number:");
            // add the Roman Number to the String variable
            secondRoman = keyboard.nextLine(); // Add the name input into the name variable
            secondRoman = secondRoman.toUpperCase();
            
            
            //Creating first instance of Roman Numbers class
            Roman firstNumber = new Roman(firstRoman);
            Roman secondNumber = new Roman(secondRoman);
            
            System.out.println("Printout of the created roman numbers");
            //Prints out the Roman Number
            firstNumber.printRoman();
            secondNumber.printRoman();
            
            
            // Convert Roman to Decimal
            firstNumber.setDecimal(firstRoman);
            secondNumber.setDecimal(secondRoman);
            
            System.out.println("Viewing the Decimal values for the two defined instances");
            //Prints decimal Numbers
            firstNumber.printDecimal();  
            secondNumber.printDecimal();
            
            System.out.println("Adding the Roman Numbers and returning new Roman value");
            Roman romanAdd;
            romanAdd = firstNumber.addRoman(secondNumber);
            romanAdd.printRoman();
    
            System.out.println("Subtracting the Roman Numbers and return new Roman value");
            Roman romanSub;
            romanSub = firstNumber.subRoman(secondNumber);
            romanSub.printRoman();
        }
    }
    CLASS:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package myname.project.pkg6;
    
    /**
     *
     * @author wsteadma
     */
    public class Roman {
    
        private String romNumber;
        private int decNumber;
    
        public Roman(String rNumber) {
            romNumber = rNumber;
        }
    
        public String getRoman() {
            return romNumber;
        }
        
        public int getDecimal()
        {
        return decNumber;
        }
    
        public void printRoman() {
            System.out.println("The Roman Number is " + romNumber);
        }
    
        public void printDecimal() {
            System.out.println("The Decimal Number is " + decNumber);
        }
    
        // Converts a roman number string into a decimal value
        public int setDecimal(String romNum) {
            int charValue = 0;
            char[] characters = new char[romNum.length()];
    
            //System.out.println("romNum length is " + romNum.length());
            for (int counter = 0; counter < romNum.length(); counter++) {
                characters[counter] = romNum.charAt(counter);
                //System.out.println(characters[counter]);
            }
    
            for (int sCounter = 0; sCounter < romNum.length(); sCounter++) {
                if (characters[sCounter] == 'M'  || characters[sCounter] == 'm') {
                    charValue += 1000;
                } else if (characters[sCounter] == 'D' || characters[sCounter] == 'd') {
                    charValue += 500;
                } else if (characters[sCounter] == 'C' || characters[sCounter] == 'c') {
                    charValue += 100;
                } else if (characters[sCounter] == 'L' || characters[sCounter] == 'l') {
                    charValue += 50;
                } else if (characters[sCounter] == 'X' || characters[sCounter] == 'x') {
                    charValue += 10;
                } else if (characters[sCounter] == 'V' || characters[sCounter] == 'v') {
                    charValue += 5;
                } else if (characters[sCounter] == 'I' || characters[sCounter] == 'i') {
                    charValue += 1;
                }
            
            }
            decNumber = charValue;
            return charValue;
        }
    
        // Converts a decomal number to a roman number
        public String setDec2Roman(int decNum) {
            String newRoman = "";
    
            while (decNum >= 1000) {
                newRoman += "M";
                decNum -= 1000;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
    
            while (decNum >= 500) {
                newRoman += "D";
                decNum -= 500;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
    
            while (decNum >= 100) {
                newRoman += "C";
                decNum -= 100;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
    
            while (decNum >= 50) {
                newRoman += "L";
                decNum -= 50;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
    
            while (decNum >= 10) {
                newRoman += "X";
                decNum -= 10;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
    
            while (decNum >= 5) {
                newRoman += "V";
                decNum -= 5;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
    
            while (decNum > 0) {
                newRoman += "I";
                decNum -= 1;
                //System.out.println(decNum);
                //System.out.println(newRoman);
            }
            return newRoman;
        }
    
        public Roman addRoman(Roman newRom) {
            int totRom = newRom.setDecimal(newRom.romNumber) + decNumber;
            romNumber = newRom.setDec2Roman(totRom);
            return new Roman(romNumber);
        }
        
        public Roman subRoman(Roman subRom) {
            int totRom = decNumber - subRom.setDecimal(subRom.romNumber);
            romNumber = subRom.setDec2Roman(totRom);
            return new Roman(romNumber);
        }
        
    }

    While (!.) Pattern.Matches ("MDCLXVI", firstRoman))

    Try "[MDCLXVI] *" and see if it's better

    {
    System.out.Print ("a valid Roman Number please try again");
    firstRoman = firstRoman.toUpperCase ();
    }

    My Code is as follows:

    // Ask for user to input firstRoman Number
    System.out.print("Enter your first Roman Number:");
    // add the Roman Number to the String variable
    firstRoman = keyboard.nextLine();
    firstRoman = firstRoman.toUpperCase();
    

    Once they enter in the it, I want to check to make sure that it has characters MDCLXVI and if it contains any other characters then I will provide a new object Scanner keyboard to try again and if it fails again, it will go to the option to try again until they put in a string that contains only the characters above. I don't know where to go here to get the while loop has worked. New to Java and I got my program work properly when I put good known numbers of novel, but I want to take incorrect entries.

    Any help would be appreciated.

    Thank you
    Wally

    I put the code for my main program and my class below just in case. I have already met the requirements of the teacher if the project is done, I'm just trying to improve.

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package myname.project.pkg6;
    
    import java.util.Scanner;
    import java.util.regex.Pattern;
    
    /**
    *
    * @author wsteadma
    */
    public class mynameProject6 {
    
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    
    // Used for testing
    String firstRoman;
    String secondRoman;
    
    Scanner keyboard = new Scanner(System.in);
    
    // Ask for user to input firstRoman Number
    System.out.print("Enter your first Roman Number:");
    // add the Roman Number to the String variable
    firstRoman = keyboard.nextLine();
    firstRoman = firstRoman.toUpperCase();
    
    // Ask for user to input secondRoman Number
    System.out.print("Enter your second Roman Number:");
    // add the Roman Number to the String variable
    secondRoman = keyboard.nextLine(); // Add the name input into the name variable
    secondRoman = secondRoman.toUpperCase();
    
    //Creating first instance of Roman Numbers class
    Roman firstNumber = new Roman(firstRoman);
    Roman secondNumber = new Roman(secondRoman);
    
    System.out.println("Printout of the created roman numbers");
    //Prints out the Roman Number
    firstNumber.printRoman();
    secondNumber.printRoman();
    
    // Convert Roman to Decimal
    firstNumber.setDecimal(firstRoman);
    secondNumber.setDecimal(secondRoman);
    
    System.out.println("Viewing the Decimal values for the two defined instances");
    //Prints decimal Numbers
    firstNumber.printDecimal();
    secondNumber.printDecimal();
    
    System.out.println("Adding the Roman Numbers and returning new Roman value");
    Roman romanAdd;
    romanAdd = firstNumber.addRoman(secondNumber);
    romanAdd.printRoman();
    
    System.out.println("Subtracting the Roman Numbers and return new Roman value");
    Roman romanSub;
    romanSub = firstNumber.subRoman(secondNumber);
    romanSub.printRoman();
    }
    }
    

    CLASS:

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package myname.project.pkg6;
    
    /**
    *
    * @author wsteadma
    */
    public class Roman {
    
    private String romNumber;
    private int decNumber;
    
    public Roman(String rNumber) {
    romNumber = rNumber;
    }
    
    public String getRoman() {
    return romNumber;
    }
    
    public int getDecimal()
    {
    return decNumber;
    }
    
    public void printRoman() {
    System.out.println("The Roman Number is " + romNumber);
    }
    
    public void printDecimal() {
    System.out.println("The Decimal Number is " + decNumber);
    }
    
    // Converts a roman number string into a decimal value
    public int setDecimal(String romNum) {
    int charValue = 0;
    char[] characters = new char[romNum.length()];
    
    //System.out.println("romNum length is " + romNum.length());
    for (int counter = 0; counter < romNum.length(); counter++) {
    characters[counter] = romNum.charAt(counter);
    //System.out.println(characters[counter]);
    }
    
    for (int sCounter = 0; sCounter < romNum.length(); sCounter++) {
    if (characters[sCounter] == 'M'  || characters[sCounter] == 'm') {
    charValue += 1000;
    } else if (characters[sCounter] == 'D' || characters[sCounter] == 'd') {
    charValue += 500;
    } else if (characters[sCounter] == 'C' || characters[sCounter] == 'c') {
    charValue += 100;
    } else if (characters[sCounter] == 'L' || characters[sCounter] == 'l') {
    charValue += 50;
    } else if (characters[sCounter] == 'X' || characters[sCounter] == 'x') {
    charValue += 10;
    } else if (characters[sCounter] == 'V' || characters[sCounter] == 'v') {
    charValue += 5;
    } else if (characters[sCounter] == 'I' || characters[sCounter] == 'i') {
    charValue += 1;
    }
    
    }
    decNumber = charValue;
    return charValue;
    }
    
    // Converts a decomal number to a roman number
    public String setDec2Roman(int decNum) {
    String newRoman = "";
    
    while (decNum >= 1000) {
    newRoman += "M";
    decNum -= 1000;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    
    while (decNum >= 500) {
    newRoman += "D";
    decNum -= 500;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    
    while (decNum >= 100) {
    newRoman += "C";
    decNum -= 100;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    
    while (decNum >= 50) {
    newRoman += "L";
    decNum -= 50;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    
    while (decNum >= 10) {
    newRoman += "X";
    decNum -= 10;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    
    while (decNum >= 5) {
    newRoman += "V";
    decNum -= 5;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    
    while (decNum > 0) {
    newRoman += "I";
    decNum -= 1;
    //System.out.println(decNum);
    //System.out.println(newRoman);
    }
    return newRoman;
    }
    
    public Roman addRoman(Roman newRom) {
    int totRom = newRom.setDecimal(newRom.romNumber) + decNumber;
    romNumber = newRom.setDec2Roman(totRom);
    return new Roman(romNumber);
    }
    
    public Roman subRoman(Roman subRom) {
    int totRom = decNumber - subRom.setDecimal(subRom.romNumber);
    romNumber = subRom.setDec2Roman(totRom);
    return new Roman(romNumber);
    }
    
    }
    
  • validate the string contains a _ using an if statement

    Hello

    I have a project that returns a serial number. I just need to validate that the serial number has a _ "underscore".

    Can anyone provide a sample if statement that returns a bollean if the string is a ____.

    Thank you

    var myString:String = "string_with_underscore";

    validate the var: Boolean = myString.indexOf ("_") >-1;

  • REGEXP_COUNT on the string containing * or /.

    Hi all

    When I run the slot request, it should return 6 but it is other than 6 back.

    Same query is executed by replacing ' |' with ' *' and other than 6 obseverd.


    Version DB: oracle 11.1.2.1

    can someone please explain why it is like that.
    SELECT REGEXP_COUNT('|us|uk|jp|ab|in|', '|', 1) REGEXP_COUNT
       FROM DUAL;
    Thank you.

    Published by: DS 17 Sep, 2012 06:54

    You must escape from the pipe, because it's a special regular expression operator.

    SQL> SELECT REGEXP_COUNT('|us|uk|jp|ab|in|', '\|', 1) REGEXP_COUNT   FROM DUAL;
    
    REGEXP_COUNT
    ------------
               6
    
  • 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

Maybe you are looking for