This doesn't create memory for you. All a pointer is is an integer describing where memory is. ...
Arrgh! No! Not that!
Seriously, in order to be perfectly clear: while a pointer may be an integer-type value, a pointer is NOT an int, nor a long, nor an unsigned int or unsigned long. A pointer is a pointer. Just because it might be the same number of bytes as a some specfic integer-type variable for whatever architecture you're coding in, that doesn't mean that relationship will hold for other architectures.
Along the same lines, size_t is size_t, NOT unsigned int.
If you screw that up and get it ingrained into your programming practices, when you move to another architecture (Can you say "64 bits"? Thank you, I knew you could!), you'll have some serious problems.
hello all,
I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element.
... (3 Replies)
I have written a program which takes a directory as command line arguments and displays all the dir and files in it.
I don't know why I have a problem with the /etc directory.It displays all the directories and files untill it reaches a sub directory called peers which is in /etc/ppp/peers.the... (4 Replies)
ive written my code in C for implementation of a simple lexical analyser using singly linked list hence am making use of dynamic allocation,but when run in linux it gives a segmentation fault is it cause of the malloc function that ive made use of????any suggestions as to what i could do???
thank... (8 Replies)
Hi ,
During execution a backup binary i get following error
"Program error 11 (Segmentation fault), saving core file in '/usr/datatools"
Riyaz (2 Replies)
Hi,
Why I don't receive a segmentation fault in the following sample.
int main(void)
{
char buff;
sprintf(buff,"Hello world");
printf("%s\n",buff);
}
If I define a buffer of 10 elements and I'm trying to put inside it twelve elements, Should I receive a sigsev... (22 Replies)
Hi,
I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
this is a network programming code to run a rock paper scissors in a client and server.
I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault.
-the segmentation fault is fixed
Current problem -Also... (3 Replies)
Hi Guys,
I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error:
"Segmentation fault"
Can someone please help me resolve this?
Thanks alot (2 Replies)
Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1...
I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one.
Below are two very condensed snippets of which I have added the results inside the each code section.
IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
LEARN ABOUT SUNOS
memset
memory(3C) Standard C Library Functions memory(3C)NAME
memory, memccpy, memchr, memcmp, memcpy, memmove, memset - memory operations
SYNOPSIS
#include <string.h>
void *memccpy(void *restrict s1, const void *restrict s2, int c, size_t n);
void *memchr(const void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
void *memmove(void *s1, const void *s2, size_t n);
void *memset(void *s, int c, size_t n);
ISO C++
#include <string.h>
const void *memchr(const void *s, int c, size_t n);
#include <cstring>
void *std::memchr(void *s, int c, size_t n);
DESCRIPTION
These functions operate as efficiently as possible on memory areas (arrays of bytes bounded by a count, not terminated by a null charac-
ter). They do not check for the overflow of any receiving memory area.
The memccpy() function copies bytes from memory area s2 into s1, stopping after the first occurrence of c (converted to an unsigned char)
has been copied, or after n bytes have been copied, whichever comes first. It returns a pointer to the byte after the copy of c in s1, or a
null pointer if c was not found in the first n bytes of s2.
The memchr() function returns a pointer to the first occurrence of c (converted to an unsigned char) in the first n bytes (each interpreted
as an unsigned char) of memory area s, or a null pointer if c does not occur.
The memcmp() function compares its arguments, looking at the first n bytes (each interpreted as an unsigned char), and returns an integer
less than, equal to, or greater than 0, according as s1 is lexicographically less than, equal to, or greater than s2 when taken to be
unsigned characters.
The memcpy() function copies n bytes from memory area s2 to s1. It returns s1. If copying takes place between objects that overlap, the
behavior is undefined.
The memmove() function copies n bytes from memory area s2 to memory area s1. Copying between objects that overlap will take place cor-
rectly. It returns s1.
The memset() function sets the first n bytes in memory area s to the value of c (converted to an unsigned char). It returns s.
USAGE
Using memcpy() might be faster than using memmove() if the application knows that the objects being copied do not overlap.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO string(3C), attributes(5), standards(5)SunOS 5.10 1 Nov 2003 memory(3C)