2

以下のコードに問題があります。

...
int anInteger;
...
//anInteger gets a value
...

int *anotherInteger;
label = (int *)malloc(sizeof(int));
strncpy(anotherInteger, anInteger, 40);

基本的に私がやりたいことは、整数からメモリを割り当てた他の整数に値をコピーすることです。これは整数間の strncpy で機能しますか、それとも別の関数が必要ですか?

4

1 に答える 1

7

逆参照するだけanotherIntegerです。

*anotherInteger = anInteger;

strncopy文字列用です。

于 2014-08-25T15:28:12.153 に答える