09-16-2013
My question is why both ppa[1][1][3], ppa[1][2][1] print out the same letter "r"?
ppa[1][2][1]is obvious, but ppa[1][1][3]seems to me not rational. Is it because [3] is out of the bounds again, which is supposed to be 2 as defined as ppa[3][2]? I am a little bit confused C automatic changes the address behind, somehow.
Thanks!
Last edited by yifangt; 09-16-2013 at 07:05 PM..
10 More Discussions You Might Find Interesting
1. Programming
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. Programming
is this a valid c declaration
int (*ptr(int *b));
plz explain... (4 Replies)
Discussion started by: areef4u
4 Replies
3. Programming
Hi I mash with pointers in C. I solve this problem about 5 hours and I don't know how I should continue.
void InsertFirst (tList *L, int val) {
tElemPtr new;
if((new = malloc(sizeof(tElemPtr))) == NULL) Error();
new->data = val;
new->ptr = L->frst;
L->frst = new;... (2 Replies)
Discussion started by: Milla
2 Replies
4. Programming
Hi all. I am trying to use restricted pointers to allow the gcc compiler optimize the code, but I have not been able to make it work so far. I am testing with this code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
void vecmult(int n, int * restrict a, int... (0 Replies)
Discussion started by: carl.alv
0 Replies
5. UNIX for Advanced & Expert Users
I am new to shared pointer conceot in C++ and hence require some clarification:
For example:
class A
{
public:
virtual ~A()
{
}
int x;
};
typedef boost::shared_ptr<A>... (1 Reply)
Discussion started by: uunniixx
1 Replies
6. Programming
I have a special character called ô. When it is declared as a character variable its showing it can be printed. But when it is declared as a character pointer variable its showing it cannot be printed. I am just wondering why its happening like this..
c1 = '@';
c2 = 'ô';
char *fp;
fp="XXô";
if... (1 Reply)
Discussion started by: sivakumar.rj
1 Replies
7. Programming
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
8. Programming
Please find the below program. the requirement and description of the program also given:
ganesh@ubuntu:~/my_programs/c/letusc/chap9$ cat fa.c.old
/* Program : write a program to count the number of 'e' in thefollowing array of pointers to strings:
char *s = {
"We will teach you how... (12 Replies)
Discussion started by: ramkrix
12 Replies
9. Programming
Hi guys.
What is the difference between these:
1. int *a;
2. int (*a); (2 Replies)
Discussion started by: majid.merkava
2 Replies
10. Programming
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
LEARN ABOUT PHP
preg_split
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)