Solved

Basic question about Srings in C

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
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.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now