hello,
I am investigating a code,which has data struct deelacration as follow:
typedef struct {
char *infile;
char inoptsbuf[10];
char *outfile;
} cmdoption_a;
cmdoption_a *cmdoption;
and intialization as follow:
cmdoption->infile=1;
cmdoption->outfile=1;
cmdoption->inoptsbuf='\0' ;
I am really confused since an integer is assign to the above variables?!!!!
any help??!!
bob
Nov 14 '05
13 1336
Robert S <b_******@yahoo .com> spoke thus: So 0 means NULL,however I thought '\0' means NULL
'\0' is NUL, the null character. It is not the same as NULL.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome. Robert S wrote:
thanks It is a transcoder proram which compile and run without a problem here is the code:
typedef struct {
char *infile; /* The input image file. */
int infmt; /* The input image file format. */
char *inopts; char inoptsbuf[OPTSMAX + 1];
char *outfile; /* The output image file. */
int outfmt;
char *outopts; char outoptsbuf[OPTSMAX + 1];
int verbose; /* Verbose mode. */
int debug;
int version;
int_fast32_t cmptno;
int srgb;
} cmdopts_t; . . . . . cmdopts_t *cmdopts;
cmdopts->infile = 0;
This line is still an error, if you have shown the entire code.
cmdopts is a pointer, but does not yet point to anything. You cannot
dereference it.
There should be something like this somewhere:
cmdopts_t xxx;
cmdopts_t *cmdopts = &xxx;
cmdopts->infmt = -1; cmdopts->inopts = 0; cmdopts->inoptsbuf[0] = '\0'; cmdopts->outfile = 0; cmdopts->outfmt = -1; cmdopts->outopts = 0; cmdopts->outoptsbuf[0] = '\0'; cmdopts->verbose = 0; cmdopts->version = 0; cmdopts->cmptno = -1; cmdopts->debug = 0; cmdopts->srgb = 0; . . . .
"Artie Gold" <ar*******@aust in.rr.com> wrote in message news:3c******** *****@individua l.net... Robert S wrote: hello, I am investigating a code,which has data struct deelacration as follow: typedef struct { char *infile; char inoptsbuf[10]; char *outfile; } cmdoption_a;
cmdoption_a *cmdoption;
and intialization as follow:
cmdoption->infile=1; cmdoption->outfile=1; cmdoption->inoptsbuf='\0' ;
I am really confused since an integer is assign to the above variables?!!!! any help??!! You *should* be confused; the code (as you've quoted it) makes no sense at all, would (should?) not compile and certainly couldn't possibly work. Why not post the *real* code (i.e. cut and paste, don't transcribe)?
I'm sure someone here could clear up any confusion.
HTH, --ag
-- Artie Gold -- Austin, Texas http://it-matters.blogspot.com (new post 12/5) http://www.cafepress.com/goldsays
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225
Christopher Benson-Manica <at***@nospam.c yberspace.org> wrote: Robert S <b_******@yahoo .com> spoke thus:
So 0 means NULL,however I thought '\0' means NULL
'\0' is NUL, the null character. It is not the same as NULL.
All the same, '\0' is a null pointer constant, so it's legal (though
massively unwise) as a value for NULL.
Richard
Richard Bos wrote: Christopher Benson-Manica <at***@nospam.c yberspace.org> wrote:
Robert S <b_******@yahoo .com> spoke thus:
So 0 means NULL,however I thought '\0' means NULL
'\0' is NUL, the null character. It is not the same as NULL.
All the same, '\0' is a null pointer constant, so it's legal (though massively unwise) as a value for NULL.
'\0' can be used anywhere that NULL can be used,
but NULL can't be used everywhere that '\0' can be used.
--
pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lawrence |
last post by:
I had some code that worked fine for several weeks, and then yesterday
it stopped working. I'm not sure what I did. Nor can I make out why it
isn't working. I'm running a query that should return 3 items from the
database. I then get a count of the return, which correctly tells me
that I've got 3 items. I then go into a for loop which I expect to
loop 3 times and print out the 3 items. Here is where things get
strange: it loops 3 times and...
|
by: Douglas Garstang |
last post by:
I can't believe I've been trying to work this out for hours now, and I
can't believe I couldn't find someone asking for a similar solution in
the newsgroups. No wonder I hate C so much, and every time I get the
textbooks out end up throwing them against the wall in rage. Thats
been going on for 10 years now.
Anyway, I have:
typedef struct _record {
int age;
|
by: someone |
last post by:
I have *thought* that setjmp/longjmp() should take a pointer to
jmp_buf. And the calling function should hold the actual struct data.
But ... I trid on both Win32 and Linux, it seems that
setjmp/longjmp() are taking stuct:
c:\> dmc sj.c (Digital Mars Compiler Version 8.38n)
link sj,,,user32+kernel32/noi;
c:\> sj.exe
sizeof(jmp_buf) = 64
----------------------------------------------------------------- sj.c
|
by: j0mbolar |
last post by:
I was reading page 720 of unix network programming,
volume one, second edition. In this udp_write function
he does the following:
void udp_write(char *buf, <everything else omitted)
struct udpiphdr *ui;
struct ip *ip;
ip = (struct ip *) buf;
|
by: leaf |
last post by:
consider these functions:
void foo()
{
cout << "foo() called;
}
void sayhello( std::string& msg ){
msg = "something";
}
int add( int x, int y)
{
| |
by: Erik de Castro Lopo |
last post by:
Hi all,
The GNU C compiler allows a void pointer to be incremented and
the behaviour is equivalent to incrementing a char pointer.
Is this legal C99 or is this a GNU C extention?
Thanks in advance.
Erik
|
by: Bill Reid |
last post by:
Bear with me, as I am not a "professional" programmer, but I was
working on part of program that reads parts of four text files into
a buffer which I re-allocate the size as I read each file. I read some
of the items from the bottom up of the buffer, and some from the
top down, moving the bottom items back to the new re-allocated
bottom on every file read.
Then when I've read all four files, I sort the top and bottom items
separately...
|
by: william |
last post by:
code segment:
long int * size;
char entry;
.............
size=&entry;
*************************************
Gcc reported 'assignment of incompatible pointer type'.
|
by: kkirtac |
last post by:
Hi, i have a void pointer and i cast it to an appropriate known type
before using. The types which i cast this void* to are, from the
Intel's open source computer vision library. Here is my piece of non-
working code:
CvMat *rowVect = cvCreateMat(1,nfeatures,CV_MAKETYPE(images-
//rowVect is a pointer to CvMat type
cvReshape( images, rowVect, 0, 1 ); //vectorize the image; readrow
is a 1xN matrix(vector)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |