Solved

Basic question about Srings in C

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stack 22 172
Problem to save 10 174
c++ substatte a varabe for a string in a LPCTSTR statment 8 89
Digital Output does not have continuity to ground? 3 101
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

830 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