Solved

Basic question about Srings in C

Posted on 2001-07-10
1
217 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

777 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