Sponsored Content
Top Forums Programming Traversing in Array of pointers Post 302428302 by Corona688 on Wednesday 9th of June 2010 12:18:29 PM
Old 06-09-2010
Code:
int n;

for(n=0; n<5; n++)
{
  char *str=s[n];
  // count all e's in s
  ...
}

 

10 More Discussions You Might Find Interesting

1. Programming

Pointers and array

hi all, let say i have a pointer exit, and this exit will store some value. how can i store the value that the pointer points to into an array and then print them out from the array. thanks in advance (2 Replies)
Discussion started by: dianazheng
2 Replies

2. UNIX for Dummies Questions & Answers

Traversing a file system

I'm pretty new at this UNIX stuff, and this may be a simple question but I'm kind of stuck :confused: Let's say I have a large directory structure of .essay files, where I saved all of the essays that I did over the last few years. Not all of the .essay files are in the same directory (all... (1 Reply)
Discussion started by: hooj
1 Replies

3. Programming

Vector Traversing

Hi i have the following structure struct S { char Mod_num; char val; char chr_nm_cd; } I am reading a 2GB file and inserting into the structure and writing into a vector. I feel like only vector will be a right option. I tried with multimap but it is memory intensive and hence i... (1 Reply)
Discussion started by: dhanamurthy
1 Replies

4. UNIX for Dummies Questions & Answers

script for traversing directory

hi please suggest a korn script which will traverse all subdirectory in the current directory? (2 Replies)
Discussion started by: ilayans
2 Replies

5. Programming

Problem with array of pointers

Hi All, I am using the array of pointers and storing the address of string.This is a global list. So i am using extern to give the reference of this list to another file and using reading the data from this string. But list is being corrupted and string is missing some characters in... (2 Replies)
Discussion started by: lovevijay03
2 Replies

6. Homework & Coursework Questions

Problem while traversing directories

I was given to create a backup of all files in a given directory(command line argument) into say /home/vishal/back and the back up files must be accordingly to the extension of the file i.e pdf files are saved in back/pdf doc files back/doc etc . I gave a recursive function to traverse through the... (1 Reply)
Discussion started by: davis7son
1 Replies

7. Shell Programming and Scripting

traversing a string

I am writing a script which will read a word and say how many vowels and consonants does the word contain. but i dont know how to traverse a string in shell scripting. if it was in C i'd have done something like this: cout<<"plz enter the word"<<endl; cin>>word; int consonants, vowels;... (4 Replies)
Discussion started by: nishrestha
4 Replies

8. Programming

Pointers and array

Hello, I read from a book exercise for a challenge. How to print out each letter of char array a by two different pointers pa and ppa in the example? I have tried my code for letter "r" by testing without full understanding as only the first one worked. #include<stdio.h> int main() { char... (17 Replies)
Discussion started by: yifangt
17 Replies

9. Programming

Traversing member of structure of vector C++

Hello, I want to loop thru a vector composed of many entries as structure, which contains sequenceID and sequence. At looping, delete any structure if the sequence is a perfect-match substring of another sequence of any other structure, so that the resulted vector contains only unique sequences.... (1 Reply)
Discussion started by: yifangt
1 Replies

10. Programming

How to Declare an array of function pointers?

I am attempting to create an array of function pointers. The examples I follow to do this are from: support.microsoft.com/en-us/help/30580/how-to-declare-an-array-of-pointers-to-functions-in-visual-c ... (3 Replies)
Discussion started by: spflanze
3 Replies
PREG_SPLIT(3)								 1							     PREG_SPLIT(3)

preg_split - Split string by a regular expression

SYNOPSIS
array preg_split (string $pattern, string $subject, [int $limit = -1], [int $flags]) DESCRIPTION
Split the given string by a regular expression. PARAMETERS
o $pattern - The pattern to search for, as a string. o $subject - The input string. o $limit - If specified, then only substrings up to $limit are returned with the rest of the string being placed in the last substring. A $limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the $flags parameter. o $flags -$flags can be any combination of the following flags (combined with the | bitwise operator): o PREG_SPLIT_NO_EMPTY - If this flag is set, only non-empty pieces will be returned by preg_split(3). o PREG_SPLIT_DELIM_CAPTURE - If this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well. o PREG_SPLIT_OFFSET_CAPTURE - If this flag is set, for every occurring match the appendant string offset will also be returned. Note that this changes the return value in an array where every element is an array consisting of the matched string at offset 0 and its string offset into $subject at offset 1. RETURN VALUES
Returns an array containing substrings of $subject split along boundaries matched by $pattern. EXAMPLES
Example #1 preg_split(3) example : Get the parts of a search string <?php // split the phrase by any number of commas or space characters, // which include " ", , , and f $keywords = preg_split("/[s,]+/", "hypertext language, programming"); print_r($keywords); ?> The above example will output: Array ( [0] => hypertext [1] => language [2] => programming ) Example #2 Splitting a string into component characters <?php $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); ?> The above example will output: Array ( [0] => s [1] => t [2] => r [3] => i [4] => n [5] => g ) Example #3 Splitting a string into matches and their offsets <?php $str = 'hypertext language programming'; $chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE); print_r($chars); ?> The above example will output: Array ( [0] => Array ( [0] => hypertext [1] => 0 ) [1] => Array ( [0] => language [1] => 10 ) [2] => Array ( [0] => programming [1] => 19 ) ) NOTES
Tip If you don't need the power of regular expressions, you can choose faster (albeit simpler) alternatives like explode(3) or str_split(3). Tip If matching fails, an array with a single element containing the input string will be returned. SEE ALSO
PCRE Patterns, preg_quote(3), implode(3), preg_match(3), preg_match_all(3), preg_replace(3), preg_last_error(3). PHP Documentation Group PREG_SPLIT(3)
All times are GMT -4. The time now is 08:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy