Solved

Basic question about Srings in C

Posted on 2001-07-10
1
222 Views
Last Modified: 2012-06-27
I have some compile error here

#include <stdio.h>
#include <string.h>
void main(void)
{
  char str[20];
  memcpy(str, "aaaaa" + "bbbbb\0",10);
  printf("here is the concated line %s",str);
 
}

error c2110 :cannot add two pointers

I programing in some environment(AS/400) and I have to port from Win32 this line :
memcpy(str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",132);
the problem is that length of line in this environment limitted to 80 chars, so what have I do ?

Thanks.
0
Comment
Question by:Maximka2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
zebada earned 50 total points
ID: 6268801
You can split a string constant like this:

memcpy(str,"aaaaa"
           "bbbbb"
           "ccccc",16);

Which is identical to

memcpy(str,"aaaaabbbbbccccc",16);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question