Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Strcpy

Reply
Thread Tools

Strcpy

 
 
Jake Thompson
Guest
Posts: n/a
 
      03-21-2006
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

 
Reply With Quote
 
 
 
 
lawrence.jones@ugs.com
Guest
Posts: n/a
 
      03-21-2006
Jake Thompson <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Default User
Guest
Posts: n/a
 
      03-21-2006
Keith Thompson wrote:

> "Default User" <(E-Mail Removed)> 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

 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      03-21-2006
On 21 Mar 2006 13:04:22 -0800, in comp.lang.c , "Jake Thompson"
<(E-Mail Removed)> 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?

 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      03-21-2006
On 21 Mar 2006 13:28:41 -0800, in comp.lang.c , "Jake Thompson"
<(E-Mail Removed)> 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
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      03-21-2006
On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"
<(E-Mail Removed)> 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
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      03-21-2006
"Jake Thompson" <(E-Mail Removed)> 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.
 
Reply With Quote
 
Jake Thompson
Guest
Posts: n/a
 
      03-21-2006
On 21 Mar 2006 13:59:53 -0800, in comp.lang.c , "Jake Thompson"


<(E-Mail Removed)> 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

 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-22-2006
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 ****ed 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


 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-22-2006
(E-Mail Removed) wrote:
> Jake Thompson <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strcpy of a class object leonkatz@gmail.com C++ 11 01-20-2005 04:44 AM
strcpy and the copy constructor RonHiler C++ 8 10-19-2004 06:30 AM
C++ Compiler with a -Wwarn-use-of-strcpy or similar option?? Paul Sheer C++ 4 09-14-2004 08:38 PM
C++ Compiler with a -Wwarn-use-of-strcpy or similar option?? Paul Sheer C++ 7 09-10-2004 05:07 PM
strcpy Mike Mimic C++ 9 05-17-2004 08:12 PM



Advertisments