Warning by strcpy at compilation...

Hi,

As we have changed our compiler, I get this warning in a program that I did not write my self.

As Im not so used to pointers, Im now somewhat unsure what to do as next.

This is how the program structure for the actual variable looks like:

In main program I call the sub-routine like this:

the variable suffix is defined in the main program as:
sting suffix

/* reading coordinates from file COORDINATES.ini */

coordinates_init(init,&Ibegin,&Iend,&Jbegin,&Jend,&I3d,&J3d,&I2d,&J2d,&Ifine,&Jfine,&suffix)

the subroutine is defined like this:

int coordinates_init(file init,int *Ibegin,int *Iend,int *Jbegin,int
*Jend, int *I3d,int *J3d,int *I2d,int *J2d, int *Ifine,int Jfine,string suf)

local definitions
char suffix[5];

gets input from default in (keyboard):

printf("\n\t Input the number of the submap: “);
scanf(”%s",suffix);

copying suffix to suf
/* SUFFIX */

strcpy(suf,suffix);



Here I get the following line from the pgcc compiler,

pgcc -O -I/Net/Groups/BSY/BSY_1/mvetter/gridbgc/include -c -o
coordinates_init.o coordinates_init.c
PGC-W-0095-Type cast required for this conversion (coordinates_init.c:
150)
PGC/x86-64 Linux/x86-64 6.1-4: compilation completed with warnings

Im not so familier with ponters, do you have a suggestion how to avoid
this warning?
The program is running with this warning, but I would be happier if I
knew how the code should be.

Many thanks in advance
Mona

The warning is from the src buffer of strcpy being defined as a const char * and you passing in a char *. You’re ok ignoring this warning, but if you want to get rid of it, use

strcpy(suf,(const char *)suffix);

Thanks alot!

For some reason it still gives the same warning message!

Then it must be from the return value. Try:

(void)strcpy(suf,(const char *)suffix)