First, please use [code][/code] where applicable
Second, a C "string" has no information about itself. It's just an array of characters, which is terminated by a null byte by convention. This also means that your two calls to sizeof will always return 4 (size of a pointer). Better add another parameter with the size of the array.
A more intelligent solution would be to malloc() the "C string" in your function, strncpy() the contents of y, and return the pointer to that memory area.
we know that sizeof never returns zero when used with structure
then why in this case it is returning zero
struct foo
{
char c;
};
void main()
{
struct foo f;
cout<<sizeof(f);
}
i am working on solaris 5.8
isn't the above function should return the size of empty structure (7 Replies)
Hi,
char *s="yamaha";
cout<<s<<endl;
int *p;
int i=10;
p=&i;
cout<<p<<endl;
1) For the 1st "cout" we will get "yamaha" as output. That is we are getting "content of the address" for cout<<s.
2) But for integer "cout<<p" we are getting the "address only".
Please clarify how we are... (2 Replies)
Hello,
I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it:
char* getext(char *file)
{
char *extension;
int i, j;... (5 Replies)
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,
is it possible to find out the size of an array of structures ( without using 'sizeof' operator). The condition is we have the array of structure instant but we are not aware of the elements inside the structure.
Can someone help me out?
Thanks in advance. (18 Replies)
Hi,
There are some bewildering sizeof() questions I have in my mind. Could anyone shed some light on this?
int main() {
printf("%d\n", sizeof(main)); // Ans: 1
}
That is, the sizeof() a function identifier though it is treated internally as a pointer gives 1 byte always, why?
... (5 Replies)
Hi,
I have defined the class and call the sizeof(object to class) to get the size.
# include <iostream>
# include <iomanip>
using namespace std;
class sample
{
private:
int i;
float j;
char k;
public:
sample()
{
} (2 Replies)
Ignoring other considerations for a moment and in general ...
Would there be a difference in result (dot oh or execution) of:
A.
strncpy( a, b, sizeof(a) );
vs.
B.
c = sizeof(a);
strncpy( a, b, c );
My general understanding is (at least I think my understanding is) that... (10 Replies)
I am passing a char* to the function "reverse" and when I execute it with gdb I get:
Program received signal SIGSEGV, Segmentation fault.
0x000000000040083b in reverse (s=0x400b2b "hello") at pointersExample.c:72
72 *q = *p;
Attached is the source code.
I do not understand why... (9 Replies)
Discussion started by: jose_spain
9 Replies
LEARN ABOUT DEBIAN
scxmlobject
ScXMLObject(3) Coin ScXMLObject(3)NAME
ScXMLObject -
Base class for all SCXML objects.
SYNOPSIS
#include <Inventor/scxml/ScXMLObject.h>
Inherited by ScXMLEvent, ScXMLInvoke, and ScXMLStateMachine.
Public Member Functions
virtual SoType getTypeId (void) const =0
SbBool isOfType (SoType type) const
void setXMLAttribute (const char *attribute, const char *value)
const char * getXMLAttribute (const char *attribute) const
virtual SbBool handleXMLAttributes (void)
virtual void setContainer (ScXMLObject *container)
ScXMLObject * getContainer (void) const
SbBool isContainedIn (const ScXMLObject *object) const
Static Public Member Functions
static SoType getClassTypeId (void)
static void initClass (void)
Static Protected Member Functions
static void registerClassType (const char *xmlns, const char *classname, SoType type)
static void registerInvokeClassType (const char *xmlns, const char *targettype, const char *source, SoType type)
Detailed Description
Base class for all SCXML objects.
Since:
Coin 3.0
Member Function Documentation
void ScXMLObject::setXMLAttribute (const char *attribute, const char *value)
This method associates a value with an attribute name. This is used for parameter passing while reading by the SCXML reader, but can be
used as a general-purpose attribute dictionary outside of that.
If NULL is passed as the value, the attribute is removed.
const char * ScXMLObject::getXMLAttribute (const char *attribute) const
This method returns the string value set for an attribute, or NULL if not set.
SbBool ScXMLObject::handleXMLAttributes (void) [virtual]
This method is called when the file reader has set all the XML attributes on the object, and wants the object to handle them and report if
the values were ok or if a read error should be produced.
Returns:
TRUE if the attributes are ok, and FALSE on error.
This base class implementation does nothing and just returns TRUE.
Reimplemented in ScXMLInvoke.
void ScXMLObject::setContainer (ScXMLObject *container) [virtual]
Set the pointer to the parent ScXML object.
SbBool ScXMLObject::isContainedIn (const ScXMLObject *object) const
This method returns TRUE if the object is contained within the given object argument. Also if they are the same, TRUE will be returned.
Otherwise, FALSE is retured.
void ScXMLObject::registerClassType (const char *xmlns, const char *classname, SoTypetype) [static], [protected]
Internal method. Friendly forwarding for ScXMLObject subclasses.
void ScXMLObject::registerInvokeClassType (const char *xmlns, const char *targettype, const char *source, SoTypetype) [static], [protected]
Internal method. Friendly forwarding for ScXMLObject subclasses.
Author
Generated automatically by Doxygen for Coin from the source code.
Version 3.1.3 Wed May 23 2012 ScXMLObject(3)