Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strcpy() ... problems ...

Status
Not open for further replies.

daniloa

Programmer
Nov 23, 2001
27
BR
Hy I'm developing i MS C++ over the Dialogic C APIs and I face this function (I think that is from C++ not Dialogic).

strcpy();

I'm using this way:

int digitos;
// Dialogic API
if (dx_getdig(pCanal, tptdig, &dig, EV_SYNC) == -1)
{
printf("Erro Pegando Digito ...\n");
strcpy(digitos,"");
}
else
{
strcpy(digitos, dig.dg_value);
}


and on the lines where are the strcpy() function when I compile I receive this error messages:

D:\Temp\Testes\Teste4\Teste4.cpp(190) : error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
D:\Temp\Testes\Teste4\Teste4.cpp(194) : error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast


Someone knows what have I to do ???

Very Thanks,

Danilo ...
 
You are passing in an int to strcpy. The first argument of strcpy takes a char*. You need to declare:

char *digitos;
digitos = new char[<size>];

Where <size> is the number of characters you are going to copy into digitos plus 1. Here is an example:

// Copy &quot;hello&quot; into digitos
char *digitos;
digitos = new char[6];
strcpy(digitos, &quot;hello&quot;);

That's it!
Hope this helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top