STRCPY [英] Strcpy

查看:153
本文介绍了STRCPY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将值复制到char *字段中。


我目前正在这样做


strcpy(cm8link.type [计数],13);


但我收到错误


错误C2664:''strcpy'':无法转换参数1从''const char''到

''char *''


这个用来当它只是cm8link.type但它出错了我做到了

cm8link.type [count]


首先为什么?


其次我怎么能得到这个数组的字段值

发生?


谢谢


杰克

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

推荐答案

Jake Thompson认为:
Jake Thompson opined:
我需要将值复制到char *字段中。 />
我目前正在做这个

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


你没有给出它的声明,但我敢打赌,上面的类型是`char`

而不是`char *`。

但我收到错误

错误C2664:''strcpy'':无法将参数1从''const char''转换为''char *''

这个曾经只用于cm8link.type,但是当它制作时它会出错

cm8link.type [count]
首先为什么?

其次,如何才能将这个阵列的价值带入该领域?
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?




请发布代码的一个小的可编辑示例,它展示了

问题(以及它的输出)。

-

BR,Vladimir


美国人最担心的是,美国会变成现象,而不是文明。

- - Shirley Hazzard,Transit of Venus



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"


Jake Thompson写道:
Jake Thompson wrote:
我需要将一个值复制到一个char *字段。

我目前正在这样做

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

但是我收到错误错误C2664:''strcpy'':无法将参数1从''const char''转换为''/' char *''

这个曾经只用于cm8link.type,但是当我制作时它会出错

cm8link.type [count]

首先为什么?


我们最后一次去了。发布一个完整的,最小的程序,

编译并演示问题。


如果没有看到
$的声明,我们怎能说些什么? b $ b变量?

其次我如何才能将该值输入到该数组的字段中?
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?




什么字段?什么阵列?我的该死的水晶球在哪里?


你不能轻易帮助我们。


Brian



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

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

Brian


首先,我很感激帮助,当然没有必要

抨击


其次我确实说过字段cm8link.type [count]是一个char *字段


我没有看到需要列出整个程序。这是一个明确我使用错误方式的一行

行声明。


简而言之,我需要将文字移动到字符*即

数组的一部分


目前作为一个例子我正在做以下事情,所以你知道数量

通常会增加一个循环,但在这里我设置它以明确定义

,我想将值13移动到


cm8link.type [2],


int count = 2;


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


导致错误


错误C2664:''strcpy'':无法将参数1从''const char''转换为


''char *''

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 *''


这篇关于STRCPY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆