473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Strcpy

I need to copy a value into a char * field.

I am currently doing this

strcpy(cm8link.type[count],"13");

but I get an error of

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to
'char *'

this used to when it was just cm8link.type but it errors when I make it
cm8link.type[count]

first of all why?

secondly how can i get the value into the field for this array
occurrence?

Thanks

Jake

Mar 21 '06 #1
55 7018
Jake Thompson opined:
I need to copy a value into a char * field.

I am currently doing this

strcpy(cm8link.type[count],"13");
You don't give its declaration, but I bet the above is of type `char`
rather than `char *`.
but I get an error of

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char'
to 'char *'

this used to when it was just cm8link.type but it errors when I make
it
cm8link.type[count]

first of all why?

secondly how can i get the value into the field for this array
occurrence?


Please post a small compilable example of your code that exhibits the
problem (and it's output).
--
BR, Vladimir

Americans' greatest fear is that America will turn out
to have been a phenomenon, not a civilization.
-- Shirley Hazzard, "Transit of Venus"

Mar 21 '06 #2
Jake Thompson wrote:
I need to copy a value into a char * field.

I am currently doing this

strcpy(cm8link.type[count],"13");

but I get an error of

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char'
to 'char *'

this used to when it was just cm8link.type but it errors when I make
it
cm8link.type[count]

first of all why?
We went over this last time. Post a COMPLETE, minimal program that
compiles and demonstrates the problem.

How can we possibly say anything without seeing the declarations of the
variables?
secondly how can i get the value into the field for this array
occurrence?


What field? What array? Where's my damn crystal ball?

You don't make easy for us to help you.

Brian

Mar 21 '06 #3
First of all I appreciate the help and certainly there is no need to
lash out

Secondly I did say that the field cm8link.type[count] is a char * field

I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.

In a nutshell I need to move a literal to a char * that is part of an
array

currently as an example I am doing the following just so you know count
is normally incremented in a loop but here i set it to clearly define
that I want to move the value 13 into

cm8link.type[2],

int count = 2;

strcpy(cm8link.type[count],"13");

resulting in the error

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to

'char *'

Mar 21 '06 #4
Jake Thompson wrote:
First of all I appreciate the help and certainly there is no need to
lash out
Nobody is lashing out at you.
Secondly I did say that the field cm8link.type[count] is a char * field

I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.


But to see how and why you're using it the wrong way, we need to see
the sorrounding relevent source, don't we?

Mar 21 '06 #5
Jake Thompson wrote:

I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.

Then figure it out yourself.

Brian
Mar 21 '06 #6
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up

Mar 21 '06 #7


Jake Thompson wrote On 03/21/06 16:04,:
First of all I appreciate the help and certainly there is no need to
lash out

Secondly I did say that the field cm8link.type[count] is a char * field
... but since the compiler contradicted you (it
described the field as `const char'), didn't it occur
to you to offer the actual code so someone could try to
judge whether you or the compiler is in error?
I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.
... and the "what's wrong with it" is clearly a
matter of context. Can you tell, without looking at
any of the rest of the program, whether the one line

x = 42;

is right or wrong? (If you think you can, you need to
re-open your C textbook.)
In a nutshell I need to move a literal to a char * that is part of an
array

currently as an example I am doing the following just so you know count
is normally incremented in a loop but here i set it to clearly define
that I want to move the value 13 into

cm8link.type[2],

int count = 2;

strcpy(cm8link.type[count],"13");

resulting in the error

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to

'char *'


You claim that `cm8link.type[2]' is a `char*', while the
compiler claims it's a `const char'. Without further evidence
it would be injudicious to say which of you is right -- but
I'm forced to disclose, right here on my jury screening form,
that I am more likely to believe the compiler's testimony than
yours. Since I am obviously prejudiced, I won't be empanelled
(a lucky break for you; I'm in a mood to hang uncooperative
witnesses).

--
Er*********@sun.com

Mar 21 '06 #8
Jake Thompson wrote:
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up


This is not a forum to throw mud at each other. Admittedly Default User
was rather curt in his reply, but the point he, I and several others
have made to you still stands, i.e. post the smallest compilable code
that exhibits your problem or failing that atleast post relevant
sarrounding code like data declarations, prototypes etc., so that we
don't have to keep guessing.

Also please quote the post to which you're replying. Most regulars in
this group, access it via nntp servers which might delete articles
after a certain time, unlike Google Groups. Including context makes the
post comprehendable in such cases.

Mar 21 '06 #9
Jake Thompson wrote:

First of all I appreciate the help and certainly there is no need to
lash out

Secondly I did say that the field cm8link.type[count] is a char * field
Obviously it's not, as the error says it's a "const char".
I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.
The problem is that without seeing the actual definition of
cm8link.type[count], people can only guess as to the "real"
problem. The compiler says one thing, and you say something
else. We tend to believe the error message over your claim
until you show us the compiler is wrong.
In a nutshell I need to move a literal to a char * that is part of an
array
An array of what?
currently as an example I am doing the following just so you know count
is normally incremented in a loop but here i set it to clearly define
that I want to move the value 13 into

cm8link.type[2],
But, what type is cm8link.type[2]? What is cm8link.type?
int count = 2;

strcpy(cm8link.type[count],"13");

resulting in the error

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to
'char *'


While tells us that cm8link.type[count] is of type "const char", and
not the "char *" that you continue to claim.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Mar 21 '06 #10

"Jake Thompson" <re***********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up


Unfortunately, his attitude is the majority here. Certain individuals will
call you off-topic or a troll despite the fact that they've only posted
complaints and have never posted anything C related:

Brian "Default User"
CBFalconer
Richard Bos
etc...
Rod Pemberton
Mar 21 '06 #11
Sorry for my outburst
This is the function that I am calling

char *folderid;
struct cm8linkstruc cm8link; <----------------structure tag set to
cm8link

struct cm8linkstruc
{
char* type; /* type of item*/
<------------------------------------------field that I want to copy
the "13" too
char* desc; /* description of item */
char* item_increment; /*increment value for item
in folder */
char* itemid; /* id of returned item */
};
These are the lines of code that I am trying to execute in order to
copy the values too.

strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
folder
strcpy(cm8link.desc[count],"Document "); //copy the description
strcpy(cm8link.desc[count],snumD); //copy the current doc counter to
the description
strcpy(cm8link.item_increment[count],snumD); //copy Document counter
cm8link.itemid[count] = ((DKPidICM*)part->getPidObject())->getItemId()
; //Get the itemid

Is this enough information to go off of?

Mar 21 '06 #12
In article <11**********************@j33g2000cwa.googlegroups .com>,
Jake Thompson <re***********@hotmail.com> wrote:
Secondly I did say that the field cm8link.type[count] is a char * field

I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.


Since you have this problem, it's clear that there's something
about the program that you don't understand. So we can't (and you
shouldn't) trust your judgement as to what is "obvious".

In particular, we can't trust your claim that cm8link.type[count]
is of type char *. Show us the whole program!

-- Richard
Mar 21 '06 #13
"Jake Thompson" <re***********@hotmail.com> writes:
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up


You need to provide context when you post a followup. Read
<http://cfaj.freeshell.org/google/>, and you'll understand how and
why.

Upthread, you wrote:

] I don't see the need to have the entire program listed. It is a one
] line statement that obviously I am using the wrong way.

If you already knew what the problem is, then presumably you wouldn't
need to ask for our help.

Conversely, the fact that you *are* asking for our help implies that
you really don't know what the problem is. If we offer you advice on
what information *we* need to help you solve *your* problem, then you
really should pay attention. We're not making you jump through hoops
just for the fun of it; we're asking you to help us to help you. If
you're unwilling to do so, then we can't help you.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 21 '06 #14
Jake Thompson wrote:
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.


As you can't be bothered to follow simple instructions when you're the
one wanting help, plus you refuse to quote any context, it's pretty
obvious what happens next.
*plonk*

Brian
Mar 21 '06 #15
On 21 Mar 2006 13:59:53 -0800, "Jake Thompson"
<re***********@hotmail.com> wrote in comp.lang.c:
Sorry for my outburst
OK, but I'm still not sure that you're getting the point.
This is the function that I am calling
You aren't showing a function at all.
char *folderid;
struct cm8linkstruc cm8link; <----------------structure tag set to
cm8link

struct cm8linkstruc
{
char* type; /* type of item*/
<------------------------------------------field that I want to copy
the "13" too
char* desc; /* description of item */
char* item_increment; /*increment value for item
in folder */
char* itemid; /* id of returned item */
};
At last, a definition of the structure! This structure contains four
members (there is no such thing as a "field" defined by the C
language), and each of the fields is a pointer to char.

Up above you show the definition of an object of this type, named
"cm8link". Since you're still not posting the real code that your
compiler is seeing, there is information lacking.

Is "cm8link" defined at file scope (outside of all functions), or is
it defined at local scope (inside of a function)? It makes a
difference, should your code ever compile, because you are heading for
a run time problem.

If "cm8link" is defined at file scope, the four char pointers are
initialized to NULL. If it is defined in a local scope, the four char
pointers are not initialized at all. In either case, they do not
point to valid memory that you can read from or write to.
These are the lines of code that I am trying to execute in order to
copy the values too.

strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
folder
I know you resent being asked for enough information to understand
what mistakes you are making, BUT WHAT THE HELL IS "count"?!? WHERE
IS "count" DEFINED?!?
strcpy(cm8link.desc[count],"Document "); //copy the description
strcpy(cm8link.desc[count],snumD); //copy the current doc counter to
the description
WHAT THE HELL IS "snumD"?!?
strcpy(cm8link.item_increment[count],snumD); //copy Document counter
cm8link.itemid[count] = ((DKPidICM*)part->getPidObject())->getItemId()
; //Get the itemid

Is this enough information to go off of?


No, actually, it is not. If you have actually properly initialized
the character pointers to valid memory that you have the right to
write to, then cm8link.desc[count] is a SINGLE CHARACTER, and you
can't copy a string into a SINGLE CHARACTER. If you haven't
initialized the character pointers, they don't point anywhere and you
can't write to them at all.

Multiple people have tried to explain to you, most of them patiently,
but you aren't getting it.

POST THE ACTUAL CODE THAT YOU ARE COMPILING. OF THE WHOLE FUNCTION.
COPY IT FROM YOUR TEXT EDITOR AND PASTE IT INTO A MESSAGE. ALSO COPY
THE DECLATATION OF EACH DATA TYPE, AND THE DEFINITION OF EACH OBJECT
THAT IS MENTIONED IN THE CODE. PASTE IT ALL INTO YOUR MESSAGE.

There are several possible different mistakes that you might be
making, and nobody here is willing to put that much effort into
guessing, maybe correctly or maybe incorrectly.

STOP TRYING TO GUESS HOW LITTLE REAL INFORMATION PEOPLE NEED TO HELP
YOU. YOU'RE GUESSING WRONG. IF YOU AREN'T WILLING TO PROVIDE
EVERYTHING I ASKED FOR ABOVE, THEN YOU SHOULD GO AWAY AND FIGURE IT
OUT FOR YOURSELF.

Now I've got a sore throat from ALL THE SHOUTING.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Mar 21 '06 #16
"Jake Thompson" <re***********@hotmail.com> writes:
Sorry for my outburst
A refreshing response, thank you. Everyone has bad moments every now
and then.
This is the function that I am calling

char *folderid;
struct cm8linkstruc cm8link; <----------------structure tag set to
cm8link

struct cm8linkstruc
{
char* type; /* type of item*/
<------------------------------------------field that I want to copy
the "13" too
char* desc; /* description of item */
char* item_increment; /*increment value for item
in folder */
char* itemid; /* id of returned item */
};
These are the lines of code that I am trying to execute in order to
copy the values too.

strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
folder
strcpy(cm8link.desc[count],"Document "); //copy the description
strcpy(cm8link.desc[count],snumD); //copy the current doc counter to
the description
strcpy(cm8link.item_increment[count],snumD); //copy Document counter
cm8link.itemid[count] = ((DKPidICM*)part->getPidObject())->getItemId()
; //Get the itemid

Is this enough information to go off of?


It's a good start.

Consider the call

strcpy(cm8link.type[count], "13");

I'll assume count is an integer object.

cm8link is of type struct cm8linkstruc.
cm8link.type is of type char*.
cm8link.type[count] is of type char
The first argument to strcpy() is a char*, not a char.

That's what you're doing wrong. What you should do is a trickier
question.

What is count? What does its value indicate? A count of what?

Since cm8link.type is a char*, it's reasonable to have it point to
(the first character of) the string "13". The simplest way to do this
is by an assignment:

cm8link.type = "13";

cm8link.type will then point to the first character of a string
literal. Allocation is taken care of for you, but you can't modify
the contents of the string.

(It might make more sense for cm8link.type to be an int, and just
assign the value 13 to it -- or better yet, use some symbolic name
like FOLDER, which could be a macro or an enum constant. But that's a
design issue, not a correctness issue.)

For a more general solution, you can either make cm8link.type point to
an existing declared object (make sure the object doesn't cease to
exist before you're done with it), or use malloc() to allocate space.
For example:

char *type = "13";
...
cm8link.type = malloc(strlen(type) + 1);
/* check whether malloc() succeeded */
strcpy(cm8link.type, type);

But it's still hard to tell just what you're trying to do. Your use
of "count" seems to imply that you want an array of something. Do you
want an array of struct cm8linkstruc objects? If so, you can either
declare an array (if you know how many you want), or you can declare a
*pointer* to a struct cm8linkstruc, and initialize it to point to an
array by calling malloc().

For example (this is a rough outline, not compiled or tested):

struct cm8linkstruc *arr_ptr;
arr_ptr = malloc(sizeof *arr_ptr * how_many);
/* check whether malloc() succeeded */
arr_ptr[count].type = "whatever";

The code fragment you posted is certainly an improvement over what
you've shown us previously, but it's still not valid C, and it's still
incomplete. We still can't really tell how it fits into any larger
context.

I suspect the underlying problem is that you're writing code too
early. You need to come up with a consistent design first, and then
express it in C code. (With enough experience, you can often write
the design directly in C, but frankly I don't think you're there yet.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 21 '06 #17

"Jake Thompson" <re***********@hotmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
First of all I appreciate the help and certainly there is no need to
lash out

Secondly I did say that the field cm8link.type[count] is a char * field

I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.

In a nutshell I need to move a literal to a char * that is part of an
array

currently as an example I am doing the following just so you know count
is normally incremented in a loop but here i set it to clearly define
that I want to move the value 13 into

cm8link.type[2],

int count = 2;

strcpy(cm8link.type[count],"13");

resulting in the error

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to

'char *'


But you were probably wrong when you said "cm8link.type[count] is a char *
field".
I'll bet that cm8link_type is a char * field, not cm8link.type[count]. In
other words,
somewhere you have:

char *cm8link.type;
of
char cm8link.type[n]; /* where n is some number */

If you want to place the characters "13" into cm8link.type beginning at
position "count", then you want:
strcpy (&cm8link.type[count], "13" );
Hopefully cm8link.type is of length at least (count+3) or you will overwrite
memory.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project

Mar 21 '06 #18
Jake Thompson wrote:
First of all I appreciate the help and certainly there is no need to
lash out
It tends to get frustrating when people ignore the advice to post enough
information to allow them to be helped.
Secondly I did say that the field cm8link.type[count] is a char * field

I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.
Since you don't know what is wrong, how do you know it isn't something
else causing the problem?

Man goes to mechanic, "my car won't start, here's the start motor, whats
the problem?"
Mechanic, "how do I know without the entire car?"

Man tries the same else where with the same result.

Swearing, man goes home and puts starter motor back in car. Man's wife
comes out and says, "what are you up to? Oh, and by the way, the car ran
out of petrol and I got some friends to help push it back here."
In a nutshell I need to move a literal to a char * that is part of an
array

currently as an example I am doing the following just so you know count
is normally incremented in a loop but here i set it to clearly define
that I want to move the value 13 into

cm8link.type[2],

int count = 2;

strcpy(cm8link.type[count],"13");

resulting in the error

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to

'char *'


That's easy. Either the error refers to a different line of
cm8link.type[count] is of type const char * despite what you claim. Of
course, there is the remote possibility that the compiler is lying, but
you being wrong about the source of the problem is *far* more likely.

In future post a *complete* program exhibiting the problem or it is
highly unlikely that anyone will bother to even try and help you.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Mar 21 '06 #19
"Default User" <de***********@yahoo.com> writes:
Jake Thompson wrote:
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.


As you can't be bothered to follow simple instructions when you're the
one wanting help, plus you refuse to quote any context, it's pretty
obvious what happens next.
*plonk*


Then you probably missed his followup, in which he wrote:

] Sorry for my outburst

FWIW.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 21 '06 #20
This is the entire function from the module

long u_dll_cm8_getfolditemmatch(char *folderid, cm8linkstruc cm8link)
{
long l_stat = 0;
short dataid;
DKFolder* dkFOL = new DKFolder();
DKParts* dkParts = new DKParts();
DKLobICM* part = new DKLobICM();
DKString list;
int numD = 0;
int numF = 0;
DKString snumD;
DKString snumF;
DKString spnumber;
int count;
short itemPropertyType;
int h;
/*Create an ddoobject based upon the passed folder id */
DKDDO* ddoObject = dsICM->createDDO(folderid);

/*Get the contents of the folder */

dkFOL = (DKFolder*)(dkCollection*)
ddoObject->getData(ddoObject->dataId(DK_CM_NAMESPACE_ATTR,DK_CM_DKFOLDER));
dataid = ddoObject->dataId(DK_CM_NAMESPACE_ATTR,DK_CM_DKFOLDER);
if(dataid==0)
{
return 1; //No items in the folder
}

dkIterator* iter = dkParts->createIterator();
count = 0;
while(iter->more()) // while there are still items, continue
searching
{
part = (DKLobICM*) iter->next()->value(); // Move pointer
to next element & get the first note found.

itemPropertyType =
part->getPropertyByName(DK_CM_PROPERTY_ITEM_TYPE);

switch(itemPropertyType)
{
case DK_CM_DOCUMENT:

numD++;
snumD = DKString(numD); //Convert number to a string
strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
folder
strcpy(cm8link.desc[count],"Document "); //copy the description
strcpy(cm8link.desc[count],snumD); //copy the current doc counter
to the description
strcpy(cm8link.item_increment[count],snumD); //copy Document
counter
cm8link.itemid[count] =
((DKPidICM*)part->getPidObject())->getItemId() ; //Get the itemid
break;

case DK_CM_FOLDER:
numF++;
snumF = DKString(numF);//Convert number to a string
strcpy(cm8link.type[count],"14"); //copy the number 14 to indicate
folder
strcpy(cm8link.desc[count],"Folder "); //copy the description
strcpy(cm8link.desc[count],snumF); //copy the current folder
counter to the description
strcpy(cm8link.item_increment[count],snumF); //copy Folder counter
cm8link.itemid[count] =
((DKPidICM*)part->getPidObject())->getItemId(); //Get the part number
break;

default:
break;
}
count++; //Increment the counter
}
delete(iter); // Free Memory
return 0;
}

This is the structure

struct cm8linkstruc
{
char* type; /* type of item*/
char* desc; /* description of item */
char* item_increment; /*increment value for item
in folder */
char* itemid; /* id of returned item */
};

As far as including the earlier text I do not know how to do that. I
am hitting reply so if I am not doing it right I apologize

Mar 21 '06 #21
Jake Thompson <re***********@hotmail.com> wrote:

First of all I appreciate the help and certainly there is no need to
lash out
Apparently, there is. When we provide advice and you ignore it,
additional emphasis is appropriate.
Secondly I did say that the field cm8link.type[count] is a char * field
Yes, you did; but it's not. If it were, you wouldn't be getting the
error you are. You have almost certainly declared it incorrectly, but
we can't tell for sure since you steadfastly refuse to show us the
actual declaration.
I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.


There are lots of things that can cause an error. If you don't know
*what* the error is, then you have no way of knowing *where* the error
is, no matter how "obvious" you might think it. Thus, it is absolutely
necessary to provide a small but complete program that generates the
error. Please delete the parts of your program that aren't related to
the error, but make sure that the end result still compiles with the
same error.

-Larry Jones

It's like SOMEthing... I just can't think of it. -- Calvin
Mar 21 '06 #22
Keith Thompson wrote:
"Default User" <de***********@yahoo.com> writes:
Jake Thompson wrote:
Well if it means dealing with a Dick as the alternative then hell yeah >> I will figure it out myself.
Thank God your attitude is the minority here.


As you can't be bothered to follow simple instructions when you're
the one wanting help, plus you refuse to quote any context, it's
pretty obvious what happens next.
plonk


Then you probably missed his followup, in which he wrote:

] Sorry for my outburst

FWIW.


Checking Google, that seems to have been in response to Kenneth. If
he'd like to specifically apologize for what he said to me, then I'd
certainly be ready to write it off as one of those things that happens
some times in a written forum. Doubtlessly someone will keep me
apprised should that transpire.

Brian

Mar 21 '06 #23
On 21 Mar 2006 13:04:22 -0800, in comp.lang.c , "Jake Thompson"
<re***********@hotmail.com> wrote:
First of all I appreciate the help and certainly there is no need to
lash out
Nobody lashed out. But if you are asked to do something out of
courtesy, and then ignore that request, expect rude responses.
Also, please read this:

<http://cfaj.freeshell.org/google/>
Secondly I did say that the field cm8link.type[count] is a char * field
Show us the definition. The error can't arise if that definition is as
you assert.
I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.


*sigh* You don't see the bug either. Do you see the connection?

Mar 21 '06 #24
On 21 Mar 2006 13:28:41 -0800, in comp.lang.c , "Jake Thompson"
<re***********@hotmail.com> wrote:
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.


You officially made it into the "arrogant newby who's too proud to
help himself" category. Well done.
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 21 '06 #25
On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"
<re***********@hotmail.com> wrote:
struct cm8linkstruc
{
char* type; /* type of item*/
type is of type char*.
strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate


Therefore type[count] is of type char.

Also, you need to allocate memory for type before you can copy
something into it.

Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 21 '06 #26
"Jake Thompson" <re***********@hotmail.com> writes:
This is the entire function from the module
But it's still not a complete program, which drastically limits how
much help we can offer.
long u_dll_cm8_getfolditemmatch(char *folderid, cm8linkstruc cm8link)
{
long l_stat = 0;
short dataid;
DKFolder* dkFOL = new DKFolder();
DKParts* dkParts = new DKParts(); [...]

According to groups.google.com, there have been 26 articles posted in
this thread. Until now, you've somehow managed to avoid posting
enough of your code to indicate that you're programming in C++, not C,
and therefore you're in the wrong newsgroup. (C and C++ are two
different languages; C has no "new" operator, among other
differences.)

If you really want help from comp.lang.c, post only C code. You may
be able to modify your code to be compatible with C (though so far you
haven't been able to show us code that's legal in any language).

Otherwise, the newsgroup you're looking for is comp.lang.c++.

Narrow down your program to a single, short, complete program, one
that doesn't depend on any external declarations or headers other than
those provided by the language standard. Show us something we can try
ourselves, and tell us what problem you're having with it. (In the
process of doing so, you might very well figure out the problem
yourself.)
As far as including the earlier text I do not know how to do that. I
am hitting reply so if I am not doing it right I apologize


We have been trying to tell you how to quote properly. Pay attention.

Read <http://cfaj.freeshell.org/google/>. Read it now. Read it
before you post another followup to this or any other newsgroup.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 21 '06 #27
On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"
<readytorid...@hotmail.com> wrote:
struct cm8linkstruc
{
char* type; /* type of item*/

type is of type char*.

strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate

Therefore type[count] is of type char.

Also, you need to allocate memory for type before you can copy
something into it.
Mark McIntyre

Mark,

If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct? Why does adding an array value to data type of
char * turn it into type char? Is there a better way to get the move
the data? I know the idea came up to turn type into an int (and that
would work for the number) but I have another strcpy statement that
copies "Document " to another char * in the struture. I would really
like to understand so I can learn from this issue.

Thanks
Jake

Can

Mar 21 '06 #28
Jake Thompson wrote:

Well if it means dealing with a Dick as the alternative then hell
yeah I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up


Have fun. PLONK. I won't be seeing you.

--
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
"We have always known that heedless self-interest was bad
morals. We now know that it is bad economics" - FDR
Mar 22 '06 #29
la************@ugs.com wrote:
Jake Thompson <re***********@hotmail.com> wrote:
.... snip ...
I don't see the need to have the entire program listed. It is
a one line statement that obviously I am using the wrong way.


There are lots of things that can cause an error. If you don't
know *what* the error is, then you have no way of knowing *where*
the error is, no matter how "obvious" you might think it. Thus,
it is absolutely necessary to provide a small but complete
program that generates the error. Please delete the parts of
your program that aren't related to the error, but make sure that
the end result still compiles with the same error.


Well, he has already been plonked for atrocious attitude by about
one-half of the people who could give him help. And that is just
those that announced it.

--
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
"We have always known that heedless self-interest was bad
morals. We now know that it is bad economics" - FDR
Mar 22 '06 #30
On 21 Mar 2006 15:36:43 -0800, in comp.lang.c , "Jake Thompson"
<re***********@hotmail.com> wrote:
If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct?
Yes
Why does adding an array value to data type of
char * turn it into type char?
it doesn't 'turn it into' anything. It just is.

'type' is a pointer to a char.

so 'type[n]' is the n-th element of an array of chars starting at
address 'type'.

This is what the notation means.

I think you need to go back to a good C book and read the chapter on
pointers and arrays. Seriously.
Is there a better way to get the move
the data?


If you want to copy data, copy it to the right type of destination,
and make sure you allocate memory.

struct foo
{
char type[12]; // an array of 12 chars
char name[36]; // ditto but 36 chars
}

struct foo bar;

strcpy (bar.type, "12");
strcpy(bar.name "Laurence Llewelyn-Bowen");
..
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Mar 22 '06 #31
Hello,

Since you are using C++, you shouldn't be using pointers. Pointers are
very difficult to use and they are the reason of many security exploits
(see for example, http://en.wikipedia.org/wiki/Buffer_overflow ).

For your code, it's incorrect. cm8link.type is a 'char *', but
cm8link.type[2] is a const char. You really should be using the C++
standard library for this:

struct cm8item {
std::string type;
std::string desc;
std::string item_increment;
std::string itemid;
};

Then, in the code,

std::vector <cm8item> cm8link;
std::cm8item tmp;
tmp.type = "14";
tmp.desc = "Folder ";
cm8link.push_back(tmp);

See the STL manual for more info:
http://www.sgi.com/tech/stl/

And, sure, comp.lang.c++ ;-)

Mar 22 '06 #32
"hdante" <hd****@gmail.com> writes:
Since you are using C++, you shouldn't be using pointers. Pointers are
very difficult to use and they are the reason of many security exploits
(see for example, http://en.wikipedia.org/wiki/Buffer_overflow ). [snip] And, sure, comp.lang.c++ ;-)


Offering C++ advice in comp.lang.c is not a good idea. Many of us
don't know C++ well enough to tell whether your advice is correct.

If the original poster wants C++ advice, he knows where to get it.
If he chooses not to post to comp.lang.c++, that's no reason to
start discussing C++ here.

Also, please provide context when you post a followup. Read
<http://cfaj.freeshell.org/google/> to understand how and why.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 22 '06 #33
The reason is simple. You don't need to scare the poster.

You are too bureaucratic. I'm outta here. See ya.

Mar 22 '06 #34
"hdante" <hd****@gmail.com> writes:
You are too bureaucratic. I'm outta here. See ya.


Don't forget to fill out Form #CLC-493 "Application To
Unsubscribe From comp.lang.c" on your way out.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Mar 22 '06 #35
Jake Thompson wrote:

If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct? Why does adding an array value to data type of
char * turn it into type char?
In C, the square brackets are used to select a member of an
array (or select an item out of a bunch of items that a pointer
is pointing to the first one of).
This is pretty basic and I suggest that you buy an introductory C
text such as "The C Programming Language" 2nd Edition by
Kernighan & Ritchie which provides a good introduction to the
language. Here is an example:

int main(void)
{
char const *str = "abcde";
char ch = str[2];

printf("The 3rd character of %s is %c.\n", str, ch);
}

Note how ch is a char and it was selected from str by using
the square brackets notation.
Is there a better way to get the move the data?
Please explain in English what you think [] means.
Nobody else on this group (me included) has yet
figured out what you are trying to do. Can you perhaps
post what you are expecting the string to be after this
operation you are attempting, and what it was beforehand?
I know the idea came up to turn type into an int (and that
would work for the number)
Huh?
but I have another strcpy statement that copies "Document "
to another char * in the struture. I would really like to
understand so I can learn from this issue.


If you are using C++ then you should use C++ string objects.
Then you can avoid advanced topics such as pointers and
memory allocation, until you are a bit more familiar with
the language.

Mar 22 '06 #36
Jake Thompson wrote:
On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"
<readytorid...@hotmail.com> wrote:
struct cm8linkstruc
{
char* type; /* type of item*/ type is of type char*.

strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate

Therefore type[count] is of type char.

Also, you need to allocate memory for type before you can copy
something into it.
Mark McIntyre

Mark,

If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct? Why does adding an array value to data type of
char * turn it into type char?


In C, the expression x[i] is identical to the expression *(x + i).[note]

Let's look at what the expression `type[count]' evaluates to, i.e.

type[count] === *(type + count)

Since `type' is a pointer to char (char *), `type + count' is also a
pointer to char. Dereferencing a pointer to char gives you a char.

[snip]

HTH,
--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
"You can't KISS* unless you MISS**"
[*-Keep it simple, stupid. **-Make it simple, stupid.]
Mar 22 '06 #37
Old Wolf wrote:
Jake Thompson wrote:
.... snip ...
Is there a better way to get the move the data?


Please explain in English what you think [] means.
Nobody else on this group (me included) has yet
figured out what you are trying to do. Can you perhaps
post what you are expecting the string to be after this
operation you are attempting, and what it was beforehand?


Before i plonked him for bad attitude, his code appeared to be a
tortuous and error riddled attempt to write a decimal string to
numeric converter. Something like strtoul, but pretty foul. Just
ignore him.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>

Mar 22 '06 #38

"Jake Thompson" <re***********@hotmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I need to copy a value into a char * field.

I am currently doing this

strcpy(cm8link.type[count],"13");

but I get an error of

error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to
'char *'

this used to when it was just cm8link.type but it errors when I make it
cm8link.type[count]


if cm8link.type was a char*, then cm8link.type[count] is a char. So you
need to pass its address, not its value: &cm8link.type[count] or just
cm8link.type + count.

However, since the message says const char, you seem to be trying to write
into something that you've declared as read-only?

--
RSH
Mar 22 '06 #39

Default User wrote:
Jake Thompson wrote:
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.


As you can't be bothered to follow simple instructions when you're the
one wanting help, plus you refuse to quote any context, it's pretty
obvious what happens next.
*plonk*


hopefully Jake Thompson isn't hoping to make a career in programming
The ability to follow instructions (eg. RTFM) is invaluable
--
Nick Keighley

Mar 22 '06 #40

Jake Thompson wrote:
This is the entire function from the module

long u_dll_cm8_getfolditemmatch(char *folderid, cm8linkstruc cm8link)
{
long l_stat = 0;
short dataid;
DKFolder* dkFOL = new DKFolder();
DKParts* dkParts = new DKParts();
DKLobICM* part = new DKLobICM();
DKString list;
int numD = 0;
int numF = 0;
DKString snumD;
DKString snumF;
DKString spnumber;
int count;
short itemPropertyType;
int h;
/*Create an ddoobject based upon the passed folder id */
DKDDO* ddoObject = dsICM->createDDO(folderid);

/*Get the contents of the folder */

dkFOL = (DKFolder*)(dkCollection*)
ddoObject->getData(ddoObject->dataId(DK_CM_NAMESPACE_ATTR,DK_CM_DKFOLDER));
dataid = ddoObject->dataId(DK_CM_NAMESPACE_ATTR,DK_CM_DKFOLDER);
if(dataid==0)
{
return 1; //No items in the folder
}

dkIterator* iter = dkParts->createIterator();
count = 0;
while(iter->more()) // while there are still items, continue
searching
{
part = (DKLobICM*) iter->next()->value(); // Move pointer
to next element & get the first note found.

itemPropertyType =
part->getPropertyByName(DK_CM_PROPERTY_ITEM_TYPE);

switch(itemPropertyType)
{
case DK_CM_DOCUMENT:

numD++;
snumD = DKString(numD); //Convert number to a string
strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
folder
strcpy(cm8link.desc[count],"Document "); //copy the description
strcpy(cm8link.desc[count],snumD); //copy the current doc counter
to the description
strcpy(cm8link.item_increment[count],snumD); //copy Document
counter
cm8link.itemid[count] =
((DKPidICM*)part->getPidObject())->getItemId() ; //Get the itemid
break;

case DK_CM_FOLDER:
numF++;
snumF = DKString(numF);//Convert number to a string
strcpy(cm8link.type[count],"14"); //copy the number 14 to indicate
folder
strcpy(cm8link.desc[count],"Folder "); //copy the description
strcpy(cm8link.desc[count],snumF); //copy the current folder
counter to the description
strcpy(cm8link.item_increment[count],snumF); //copy Folder counter
cm8link.itemid[count] =
((DKPidICM*)part->getPidObject())->getItemId(); //Get the part number
break;

default:
break;
}
count++; //Increment the counter
}
delete(iter); // Free Memory
return 0;
}

This is the structure

struct cm8linkstruc
{
char* type; /* type of item*/
char* desc; /* description of item */
char* item_increment; /*increment value for item
in folder */
char* itemid; /* id of returned item */
};

As far as including the earlier text I do not know how to do that. I
am hitting reply so if I am not doing it right I apologize

when you are asked to post a short complete example that exhibts the
problem you should have posted something like this:-

struct cm8linkstruc
{
char* type; /* type of item*/
char* desc; /* description of item */
char* item_increment; /*increment value for
item in folder */
char* itemid; /* id of returned item */
};

long u_dll_cm8_getfolditemmatch (char *folderid, cm8linkstruc cm8link)
{
int count;

strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
folder`
return 0;
}
see? easy. I suggest you learn to accept advice if you want people to
help you.
--
Nick Keighley

Mar 22 '06 #41
Jake Thompson wrote:
I don't see the need to have the entire program listed. It is a one
line statement that obviously I am using the wrong way.
If you don't understand the problem, you don't understand what's
/relevant/ to the problem. You're asking us to guess what else
you've done. We might guess wrong. We might waste your time and
ours with our wrong guesses.

If you construct a complete, minimal example that shows the
problem, you might solve it for yourself in the process. Hooray!
Otherwise, we can see /exactly/ what code you used and get to
the heart of the problem immediately. Hooray!

Otherwise, we are treading in mud, wearing streaky glasses and
breathing acrid dust. No hooray. BOOM tomorrow.
error C2664: 'strcpy' : cannot convert parameter 1 from 'const char' to
'char *'


Well, that's a pretty straightforward diagnostic. Parameter 1 of
strcpy should be a char*, but you gave it a const char. Don't do
that.

--
Chris "x.f(y) == f(x, y) == (x, y).f" Dollin
The shortcuts are all full of people using them.
Mar 22 '06 #42
Ben Pfaff wrote:

"hdante" <hd****@gmail.com> writes:
You are too bureaucratic. I'm outta here. See ya.


Don't forget to fill out Form #CLC-493 "Application To
Unsubscribe From comp.lang.c" on your way out.


.... in triplicate. Keep the white form, send the yellow form to the
comp.lang.c owner, and the blue form gets submitted with your copy of
Form #CLC++001 "Application To Subscribe To comp.lang.c++". (The
green copy is no longer needed.)

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Mar 22 '06 #43
(Quoting corrected.)

Jake Thompson wrote:

On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"

<readytorid...@hotmail.com> wrote:
struct cm8linkstruc
{
char* type; /* type of item*/
type is of type char*.
strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate


Therefore type[count] is of type char.

Also, you need to allocate memory for type before you can copy
something into it.

Mark McIntyre


Mark,

If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct?


Correct.
Why does adding an array value to data type of
char * turn it into type char?
While, technically, a "char *" is a "pointer to char", it is typically
used as a "pointer to an array of chars".

Think of it this way:

char *welcome = "Hello, world\n";

"welcome" is a "char *", pointing to the string "Hello, world\n", but
"welcome[3]" is a "char" with a value of 'l'. For the same reason,
"cm8link.type" is a "char *", but "cm8link.type[count]" is a char.
Is there a better way to get the move
the data? I know the idea came up to turn type into an int (and that
would work for the number) but I have another strcpy statement that
copies "Document " to another char * in the struture. I would really
like to understand so I can learn from this issue.


What, exactly, are you trying to do with the statement:

strcpy(cm8link.type[count],"13");

Is it possible that you really want:

strcpy(cm8link.type+count,"13");

which will store the three characters '1', '3', '\0' starting at the
given offset within the buffer?

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Mar 22 '06 #44

Kenneth Brody wrote:
(Quoting corrected.)

Jake Thompson wrote:

On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"

<readytorid...@hotmail.com> wrote:
>struct cm8linkstruc
>{
> char* type; /* type of item*/

type is of type char*.

>strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate

Therefore type[count] is of type char.

Also, you need to allocate memory for type before you can copy
something into it.

Mark McIntyre


Mark,

If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct?


Correct.
Why does adding an array value to data type of
char * turn it into type char?


While, technically, a "char *" is a "pointer to char", it is typically
used as a "pointer to an array of chars".

Think of it this way:

char *welcome = "Hello, world\n";

"welcome" is a "char *", pointing to the string "Hello, world\n", but
"welcome[3]" is a "char" with a value of 'l'. For the same reason,
"cm8link.type" is a "char *", but "cm8link.type[count]" is a char.
Is there a better way to get the move
the data? I know the idea came up to turn type into an int (and that
would work for the number) but I have another strcpy statement that
copies "Document " to another char * in the struture. I would really
like to understand so I can learn from this issue.


What, exactly, are you trying to do with the statement:

strcpy(cm8link.type[count],"13");

Is it possible that you really want:

strcpy(cm8link.type+count,"13");

which will store the three characters '1', '3', '\0' starting at the
given offset within the buffer?

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>


Ulitmately what I want to do is build an array of values so that I can
take each occurence of count(my array incrementor) to use it to build a
what I call a link list in another function
What I do is allocate my array in one function and then pass it to my
secondary function so that I can loop through an index and when I get a
hit on a certain type I want to store it away as an occurence

for example say I i loop through 10 items in the secondary function and
two of those items match my criteria - at that point in time I want to
store 4 things in an array for that occurrence

Those four things are
type ,desc, item_increment, and itemid
Occurence 1

type = "13"
desc = "Document"
item_increment =Document1"
itemid p75554

Occurence 2

type = "13"
desc = "Document"
item_increment =Document2"
itemid p76666

When I return to the calling function I want to be able to loop through
the newly built array that has the two occurrences and build my link
list

I used char * for my field types because I wanted to use functions
strcpy and strcat in order to manipulate some of the data specifically
item_increment where I concatenate a number onto the desc field.

Jake

Mar 22 '06 #45
Kenneth Brody wrote:
Ben Pfaff wrote:
"hdante" <hd****@gmail.com> writes:
You are too bureaucratic. I'm outta here. See ya.


Don't forget to fill out Form #CLC-493 "Application To
Unsubscribe From comp.lang.c" on your way out.


... in triplicate. Keep the white form, send the yellow form to
the comp.lang.c owner, and the blue form gets submitted with your
copy of Form #CLC++001 "Application To Subscribe To comp.lang.c++".
(The green copy is no longer needed.)


Use a ball point pen and press heavily. You are making 4 copies.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Mar 22 '06 #46

"Rod Pemberton" <do*********@sorry.bitbuck.cmm> wrote in message
news:dv***********@news3.infoave.net...

"Jake Thompson" <re***********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up
Unfortunately, his attitude is the majority here. Certain individuals

will call you off-topic or a troll despite the fact that they've only posted
complaints and have never posted anything C related:

Brian "Default User"
CBFalconer
Richard Bos
etc...


I forgot to add a few people to that list who just try to kill conversation.
You can see from their follow up posts I speak the truth:

Al "Em" Balmer
Keith "Kill It" Thompson
Mark "The Ass" McIntyre
CB "PLONK" Falconer

Some of these guys are just ridiculous. I think Falconer is going for the
world record in calling people troll's. He's used "PLONK" two hundred and
ninety-three times and still hasn't contributed anything topical or
non-topical.
Rod Pemberton
Mar 22 '06 #47

Jake Thompson wrote:
Kenneth Brody wrote:
(Quoting corrected.)

Jake Thompson wrote:

On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"
>
> <readytorid...@hotmail.com> wrote:
> >struct cm8linkstruc
> >{
> > char* type; /* type of item*/
>
> type is of type char*.
>
> >strcpy(cm8link.type[count],"13"); //Copy the number 13 to indicate
>
> Therefore type[count] is of type char.
>
> Also, you need to allocate memory for type before you can copy
> something into it.
>
> Mark McIntyre

Mark,

If I am understanding you correctly type is a char * and type[count] is
a char. Is is correct?


Correct.
Why does adding an array value to data type of
char * turn it into type char?


While, technically, a "char *" is a "pointer to char", it is typically
used as a "pointer to an array of chars".

Think of it this way:

char *welcome = "Hello, world\n";

"welcome" is a "char *", pointing to the string "Hello, world\n", but
"welcome[3]" is a "char" with a value of 'l'. For the same reason,
"cm8link.type" is a "char *", but "cm8link.type[count]" is a char.
Is there a better way to get the move
the data? I know the idea came up to turn type into an int (and that
would work for the number) but I have another strcpy statement that
copies "Document " to another char * in the struture. I would really
like to understand so I can learn from this issue.


What, exactly, are you trying to do with the statement:

strcpy(cm8link.type[count],"13");

Is it possible that you really want:

strcpy(cm8link.type+count,"13");

which will store the three characters '1', '3', '\0' starting at the
given offset within the buffer?

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>


Ulitmately what I want to do is build an array of values so that I can
take each occurence of count(my array incrementor) to use it to build a
what I call a link list in another function
What I do is allocate my array in one function and then pass it to my
secondary function so that I can loop through an index and when I get a
hit on a certain type I want to store it away as an occurence

for example say I i loop through 10 items in the secondary function and
two of those items match my criteria - at that point in time I want to
store 4 things in an array for that occurrence

Those four things are
type ,desc, item_increment, and itemid
Occurence 1

type = "13"
desc = "Document"
item_increment =Document1"
itemid p75554

Occurence 2

type = "13"
desc = "Document"
item_increment =Document2"
itemid p76666

When I return to the calling function I want to be able to loop through
the newly built array that has the two occurrences and build my link
list

I used char * for my field types because I wanted to use functions
strcpy and strcat in order to manipulate some of the data specifically
item_increment where I concatenate a number onto the desc field.

Jake


Well I figured it out - I had my subscript in the wrong location

I had cm8link.type[count] when I should of had cm8link[count].type

thanks to all that provided helpful replies

Mar 22 '06 #48
Rod Pemberton schrieb:
"Rod Pemberton" <do*********@sorry.bitbuck.cmm> wrote in message
news:dv***********@news3.infoave.net...
"Jake Thompson" <re***********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.google groups.com...
Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up
Unfortunately, his attitude is the majority here. Certain individuals
will call you off-topic or a troll despite the fact that they've only
posted complaints and have never posted anything C related:

Brian "Default User"
CBFalconer
Richard Bos
etc...


Funny, you seem to miss their C posts that I see.
I forgot to add a few people to that list who just try to kill conversation.
You can see from their follow up posts I speak the truth:

Al "Em" Balmer
Keith "Kill It" Thompson
Mark "The Ass" McIntyre
CB "PLONK" Falconer

Some of these guys are just ridiculous. I think Falconer is going for the
world record in calling people troll's. He's used "PLONK" two hundred and
ninety-three times and still hasn't contributed anything topical or
non-topical.


Apart from Chuck's "open plonk" policy and the number of plonks
you counted (which I did not), this is plainly wrong.

I suggest that you review the average "quality" of _your_
contributions, as it suffers by your pointless diatribes.

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 22 '06 #49

"Michael Mair" <Mi**********@invalid.invalid> wrote in message
news:48************@individual.net...
Rod Pemberton schrieb:
"Rod Pemberton" <do*********@sorry.bitbuck.cmm> wrote in message
news:dv***********@news3.infoave.net...
"Jake Thompson" <re***********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.google groups.com...

Well if it means dealing with a Dick as the alternative then hell yeah
I will figure it out myself.

Thank God your attitude is the minority here.

I don't know who pissed in your breakfast but dude lighten up

Unfortunately, his attitude is the majority here. Certain individuals
will call you off-topic or a troll despite the fact that they've only
posted complaints and have never posted anything C related:

Brian "Default User"
CBFalconer
Richard Bos
etc...
Funny, you seem to miss their C posts that I see.

I've seen two from CBFalconer today, after I posted this. The first in four
months.
I forgot to add a few people to that list who just try to kill conversation. You can see from their follow up posts I speak the truth:

Al "Em" Balmer
Keith "Kill It" Thompson
Mark "The Ass" McIntyre
CB "PLONK" Falconer

Some of these guys are just ridiculous. I think Falconer is going for the world record in calling people troll's. He's used "PLONK" two hundred and ninety-three times and still hasn't contributed anything topical or
non-topical.


Apart from Chuck's "open plonk" policy and the number of plonks
you counted (which I did not),


This isn't the only group he spams. That's his Google cached total.
this is plainly wrong.

I suggest that you review the average "quality" of _your_
contributions, as it suffers by your pointless diatribes.


Diatribes, perhaps. Pointless, no. They are an attempt to bring an
awareness of the fact that a small group is castigating hundreds, and
perhaps thousands of others over time, in this newsgroup. Castigation which
is uncalled for and unnecessary. If you were subscribed to any other
newsgroup, you'd know this to be true. If I must be the sacrificial pawn to
bring about this awareness, then so be it. It's truly unfortunate that you
choose to defend the strong at the expense of the weak. I doubt anyone
would call you noble.
Rod Pemberton
Mar 22 '06 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Paul Sheer | last post by:
I need to automatically search and replace all fixed size buffer strcpy's with strncpy's (or better yet, strlcpy's) as a security and stability audit. The code base is large and it is not feasable...
9
by: Ape Ricket | last post by:
Hi. During my program's set-up phase where it reads in the arguments it was invoked with, I programmed this: if (strcmp(argv,"-G") ==0) { geom_scaling = ON; if (i < argc-1)...
9
by: Pascal Damian | last post by:
I read somewhere that strcpy() is safer when dealing with malloc()-ed strings. Is that true? (Of course I know that both are unsafe). -- Pascal
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
302
by: Lee | last post by:
Hi Whenever I use the gets() function, the gnu c compiler gives a warning that it is dangerous to use gets(). Is this due to the possibility of array overflow? Is it correct that the program...
3
by: naren | last post by:
Iam not getting the correct pros and cons of the strcpy() and memcpy() some where i read for short strings strcpy is faster and for large strings memcpy is faster.. in strcpy() there is a single...
9
by: jim | last post by:
i want to make a c file that i can 'scanf ' students scores of 2 classes and their names , and i want it to get the sum of the 2 scores and make them in order .at last 'printf' /*am sorry,my...
38
by: edu.mvk | last post by:
Hi I am using strcpy() in my code for copying a string to another string. i am using static char arrays. for the first time it is exected correctly but the second time the control reaches...
77
by: arnuld | last post by:
I have created my own implementation of strcpy library function. I would like to have comments for improvements: /* My version of "strcpy - a C Library Function */ #include <stdio.h>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.