Below is the program i tried to execute......
main()
{
static int a = {0,1,2,3,4};
static int *p = {a, a+1, a+2, a+3, a+4};
printf (“\n %u %u %d”, p, *p, *(*p) );
}
This works, but i wanted to know why both a and *p are declared as "static". If we dont declare a as static... (2 Replies)
HI,
Here is some thing that is puzzling me from a long time.
Can some body explain me this with example.
The question is :-
What is the difference between function pointer and pointer to a function.
Where do we actually use the function pointers and pointer to functions.
Thanks in... (0 Replies)
Hi all
i wonder about function pointers as i never used them in my C code .
could any tell me why and where exactly function pointers come into
picture .
thanq (1 Reply)
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)
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)
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)
Hi guys, I'm trying to understand pointers in C and made a simple example and I've problems with It.
Can someone help?
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int f1(char **str_);
int main(int argc, char **argv)
{
char *str = NULL;
f1(&str);
... (3 Replies)
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
LEARN ABOUT DEBIAN
strcstr
STRCSTR(3pub) C Programmer's Manual STRCSTR(3pub)NAME
strcstr - convert memory block to printable C string notation
SYNOPSIS
#include <publib.h>
void strcstr(char *str, size_t max, const void *block, size_t n);
DESCRIPTION
strcstr converts the contents of an arbitrary memory block (which need not be a zero terminated string) into a printable notation using
normal C string literal syntax. This can be used for example to store potentially binary data in a file, or in debugging outputs.
All characters for which there is a simple shorthand escape sequence (', ", ?, , a, , f,
,
, , v) are stored using that nota-
tion. is stored as . All other non-printable characters are stored using a hexadecimal escape sequence. All other printable charac-
ters are stored as is.
The isprint(3) macro is used to determine whether a character is printable (i.e., whether it is printed as is, or using special notation).
Therefore, the output depends on the locale.
RETURN VALUE
strcstr returns nothing.
EXAMPLE
The following code dumps input to the standard output in a guaranteed (modulo locale bugs) printable format. It might be used for debug-
ging.
#include <stdio.h>
#include <publib.h>
int main(void) {
char line[512];
char cstr[512*(CHAR_BIT/4+1+2)+1]; /* +2 for x, +1 for ,
the rest to be able to
store the hex code for
512 chars. */
while (fgets(line, sizeof(line), stdin) != NULL) {
strcstr(cstr, sizeof(cstr), line, strlen(line));
printf("%s0, cstr);
}
return 0;
}
SEE ALSO publib(3), strins(3)AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi)
Publib C Programmer's Manual STRCSTR(3pub)