473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

2 dimensional strcpy err

char chain[10][300];
strcpy(chain[i+20], chain[i]);
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
how to amend that?
Nov 14 '05 #1
7 3667
Guy
strcpy((char*)chain + 300*(i+20) , (char*)chain + 300*i);
~ ªÑ²¼»ù®æ¦³¤É¦³¶^, ¶R½æ*n¯à©Ó¾á*·ÀI ~

~ Samba, more than a low cost File and Printer server ~

-- Let us OpenSource --
Nov 14 '05 #2
Ross <kk******@cuhk.edu.hk> wrote:
char chain[10][300]; strcpy(chain[i+20], chain[i]); 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 how to amend that?


First thing I would try to do in your case would be to invoke your
compiler in C and not C++ mode. Second, you should make sure that
you don't use array elements that don't exist. With the above 'i'
would have to be between -20 and -11 in order not to access an
element outside of the 'chain' array for the first argument to
strcpy(), but, on the other hand, 'i' has to be between 0 and 20
for the second argument - which it obviously can't be both at the
same time.
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #3
Ross wrote:
char chain[10][300]; strcpy(chain[i+20], chain[i]); 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 how to amend that?


Use a C compiler. You are using a C++ compiler. If your product claims
to compile both C and C++, then it has different ways of invoking it for
the two different languages. Read the documentation.

Nov 14 '05 #4
"Ross" <kk******@cuhk.edu.hk> writes:
char chain[10][300];
strcpy(chain[i+20], chain[i]);
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


As others have mentioned, you should invoke your compiler in C mode
rather than C++ mode, but I don't think that's your problem.

The first argument to strcpy is of type char[300], which is converted
to char*. The compiler is saying that it's of type char. The only
explanation I can think of is that the code you posted isn't the same
as the code you're trying to compile.

If you post a code sample, you need to cut-and-paste the *exact* code;
we can't guess what your actual code looks like.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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.
Nov 14 '05 #5
On 26 Dec 2004 00:27:22 +0800, "Guy" <bo*********@hotmail.com> wrote
in comp.lang.c:
strcpy((char*)chain + 300*(i+20) , (char*)chain + 300*i);


There are so many things wrong with this post that I'm not even going
to try to correct them.

To anyone reading this post: DON'T DO THIS.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #6
Ross wrote on 25/12/04 :
char chain[10][300];

strcpy(chain[i+20], chain[i]);

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


First of all, be sure you are using a C compiler. The file extension
should be .c (lowercase) and not .cpp or .C (uppercase).

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Clearly your code does not meet the original spec."
"You are sentenced to 30 lashes with a wet noodle."
-- Jerry Coffin in a.l.c.c++

Nov 14 '05 #7
Ross wrote:
char chain[10][300];
strcpy(chain[i+20], chain[i]);
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
how to amend that?


First of all - post real code. The code you provided cannot result in
the above error message.

--
Best regards,
Andrey Tarasevich
Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
1
by: Reginald Carlier | last post by:
Hi, I'm programming a game and one of the variables is a two dimensional array in wich I store the names of the players. So far so good; with cin.get I ask the names of the players and...
6
by: Ruben | last post by:
I'm trying to pass an array of string to a function without knowing how many strings I have beforehand. I've defined one functions as char * insert(char table,int cols, char values); out of...
11
by: miketigerwoods | last post by:
I'm having problems where I need to parse a command line, and place each token from strtok() into an array. I've read here: http://www.phim.unibe.ch/comp_doc/c_manual/C/CONCEPT/arrays.html (at...
302
by: Lee | last post by:
Hi Whenever I use the gets() function, the gnu c compiler gives a warning that it is dangerous to use gets(). Is this due to the possibility of array overflow? Is it correct that the program...
22
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
31
by: mdh | last post by:
I am still having a problem understanding K&RII on p 112. I have looked at the FAQs --which I am sure answer it in a way that I have missed, so here goes. A 2-dim array, (per K&R) is really a...
4
by: Paul David Buchan | last post by:
Hello, I'm attempting to write a program to read in database files (.dbf). When I do it all as a single procedure in main, everything works. However, what I really want, is to pass the database...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.