Robert Ryan wrote:
> #include<stdio.h>
> #include<string.h>
> int main()
> {
>         char *s1[7]="hello1";     // 5
>         char *s2[7]="hello2";     // 6
>         {
>               strcpy(s1, s2);        // 8       
>                printf("%s\n", s1, s2);
>         }
> }
> 
> 
> 7-26C++.cpp: In function `int main()':
> 7-26C++.cpp:5: invalid initializer
> 7-26C++.cpp:6: invalid initializer
> 7-26C++.cpp:8: cannot convert `char**' to `char*' for argument `1' to `char*
>    strcpy(char*, const char*)'
> 
> 
> --- On Sat, 7/26/08, Oliva Lukas <[EMAIL PROTECTED]> wrote:
> From: Oliva Lukas <[EMAIL PROTECTED]>
> Subject: Re: [c-prog] Segmentation fault
> To: [email protected]
> Date: Saturday, July 26, 2008, 11:11 AM
> 
>               Maybe to be more specific,
> 
> you should use array of chars for string representation, so for "hello",
> 
>   char s1[7] = "hello";
> 
> should be used.
> 
> 
> 
> Lukas Oliva

Well, that error occurs because you aren't paying attention to what 
Lukas said and decided to make a syntax error out of the whole issue. 
The error is as it says it is.

I've noticed that you consistently post the same things over and over 
and over again.  You appear to be attempting to learn by trial-and-error 
- the worst possible way to learn C/C++.  You most likely won't learn 
anything and will generally get frustrated and give up.

Learning from a book is the best way to go.  Do yourself a favor and get 
a good book and only use this group when you are _truly_ stuck.  The 
problems you are having are very basic.

When you joined c-prog, you should have received an e-mail containing 
the group welcome message. In that message was a list of books that you 
should read. Just in case you missed the message, here is that list of 
books again and the order in which you should be reading them:

"Accelerated C++" by Koenig and Moo (ISBN #020170353X)
"Safe C++ Design Principles" by Thomas Hruska
"The C++ Standard Library" by Nicolai Josuttis (ISBN #0201379260)
"Effective C++" by Scott Meyers (ISBN #0201924889)
"More Effective C++" by Scott Meyers (ISBN #020163371X)

If you are learning or looking to learn C, consider learning C++ 
instead. It is much more versatile and offers powerful features that C 
doesn't offer. If you happen to be already reading something other than 
the books above, seriously consider supplementing or replacing your book 
with the above.

If you can't afford the books mentioned, Bruce Eckel offers "Thinking in 
C++" for free from his website:

http://mindview.net/Books/TICPP/ThinkingInCPP2e.html


And the group owner, Thomas Hruska, has generously donated his book 
"Safe C++ Design Principles" to c-prog group members for free:

http://tech.groups.yahoo.com/group/c-prog/files/Books/


Beware any C/C++ author who does not adhere closely to the ANSI C/C++ 
Standard. One very popular author is Yashavant Kanetkar who is the 
author of "Let Us C". His writing may be simple to understand however 
his code is non-ANSI Standard. Similar great writers have shown up over 
the years who tell wonderful stories but don't adhere to the Standards 
defined by the ANSI C/C++ committees.

You should also obtain at least copy of a draft copy of the ANSI C/C++ 
Standard. Draft copies are free and c-prog links to quite a few of them 
here:

http://tech.groups.yahoo.com/group/c-prog/links/Standards_001012496381/


-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to