#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main(){
int start = 3;
int stop = 9;
const char src[] = "A test string";
// print 6 char from src+start
printf("%.*s\n",stop-start, src + start);
// &src[3] == src+3
printf("%s %s\n", &src[3], src+3);
// what is src+start ?
printf("src + %d = %s\n",start,src+start);
// print nchar from src+start
int nchar = 9;
printf("%.*s\n",nchar, src + start);
}
Code:
$ gcc test2.c
$ ./a.out
est st
est string est string
src + 3 = est string
est strin
---edit----
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main(){
int start = 3;
int stop = 9;
const char src[] = "A test string";
// I confused from variable "count" that whether you like to print "char-start to char-stop" '3 - 9' or n char from start ?unsigned int count = stop - start;
// print 6 char from src+start
printf("char %d-%d = %d ~ %.*s\n",start,stop,count,count, src + start);
// n char specified in stop from starting
printf("Total char %d from start ~ %.*s\n",stop,stop,src + start);
}
Code:
$ ./a.out
char 3-9 = 6 ~ est st
Total char 9 from start ~ est strin
Last edited by Akshay Hegde; 01-18-2014 at 01:24 PM..
This User Gave Thanks to Akshay Hegde For This Post:
void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (1 Reply)
All ..
I am having a pointer array . And trying to store the addess into that pointer array . please see below the problem i faced
code:
int cnt1;
char *t_array;
char *f_array;
for(cnt1=0; cnt1<1000; cnt1++)
{
t_array =... (1 Reply)
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Hi all,
Can anyone provide help with getting the right syntax regarding array/pointers in C in the following code? Can't locate a specific example which clarifies this...
Say I declare a typedef to an array of pointers to some type...
/**
* An array of ptrs to sections
*/
typedef... (4 Replies)
if i create an array of pointers to a structure "struct node" as:
struct node *r;
and create "n" number of "linked lists" and assign it to the various struct pointers r using some function with a return type as structure pointer as:
r=multiplty(.......) /*some parameters*/
is... (2 Replies)
Hi guys,
Besides the points bellow, what would best practices for scripting be ?
1) set the PATH
2) unset the current environment (set -u ?)
3) (re)set the IFS to default value - space (IFS="" <- is this correct ?)
4) check the return code for each action inside the script (cd, rsync,... (1 Reply)
I am struggling with the pointer to 2D-array (cf: 2D array of pointers). Can anybody help me elaborate how the pointer x moves in the memory to access the individual of y, especially the high lighted lines?
I have talked to one of the curators of the forum, but I am still not quite clear.
Here... (1 Reply)
Discussion started by: yifangt
1 Replies
LEARN ABOUT OPENSOLARIS
fcutf8len
FcUtf8Len(3)FcUtf8Len(3)NAME
FcUtf8Len - count UTF-8 encoded chars
SYNOPSIS
cc [ flag... ] file... -lfontconfig [ library... ]
#include <fontconfig.h>
FcBool FcUtf8Len (FcChar8 *src, int len, int *nchar, int *wchar);
DESCRIPTION
Counts the number of Unicode chars in len bytes of src. Places that count in nchar. wchar contains 1, 2 or 4 depending on the number of
bytes needed to hold the largest unicode char counted. The return value indicates whether src is a well-formed UTF8 string.
VERSION
Fontconfig version 2.5.0
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWfontconfig |
+-----------------------------+-----------------------------+
|Interface Stability |Volatile |
+-----------------------------+-----------------------------+
|MT-Level |See XInitThreads(3X11) |
+-----------------------------+-----------------------------+
13 November 2007 FcUtf8Len(3)