Questions tagged [strcpy]

The C standard library function, "strcpy()," is used to copy non-overlapping, null-terminated strings. It is also defined as "std::strcpy()" in the C++ standard library.

Used to copy null-terminated, non-overlapping strings, it is defined in the <string.h> standard header. It is also defined in the C++ standard library in the <cstring> header.

Documentation for C strcpy.

Documentation for C++ std::strcpy.

947 questions
0
votes
1 answer

Android NDK strcpy crashes when I try to put copy a String

This is what I am trying to do: static char* callerURI; //declared globally strcpy(callerURI, reqParticipants.URI[idUser]); Where : @var VidyoClientRequestParticipants::URI [out] Array of values for Vidyo URI of remote participants in a…
rosu alin
  • 5,674
  • 11
  • 69
  • 150
0
votes
3 answers

segmentation fault in my code with strcpy

I am getting segmentation fault after strcpy(buffer_two, argv[1]); Not sure what's going wrong here and i would appreciate a hand to understand what's wrong and why i get that segmentation fault. #include #include int main(int…
Smith
  • 1
  • 2
0
votes
1 answer

What is this error? cannot convert 'char**' to 'char*' for argument '1' to 'char* strcpy(char*, const char*)

#define NAME_LEN 20 #include "stdio.h" #include "stdlib.h" #include "string.h" #pragma warning(disable:4996) typedef struct bank { char *name[NAME_LEN]; int id; int money; struct bank *next; } bank; bank *head, *tail; // 노드의…
0
votes
1 answer

strcpy crashes the program

Source code: priorityqueue_t * pqueue_create() { priorityqueue_t *pq; pq = (priorityqueue_t *) malloc(sizeof(priorityqueue_t)); pq->entries = (pqentry_t **) malloc(4 * sizeof(pqentry_t *)); pq->last = 0; pq->size = 4; …
Truut
  • 83
  • 1
  • 11
0
votes
1 answer

C++/Arduino: strcpy(), strncpy() and memcpy() on unsigned char not working

I am trying to implement AES-128 and AES-256 on an Arduino (Adafruit Feather M0, for any other people using SAMD21 processors!). The encryption and decryption is working, but I am unable to “save” the encrypted value. I believe the example passes a…
user5156141
  • 655
  • 9
  • 29
0
votes
1 answer

Different performance between glibc and same code

I am developing a program that copy string. And I checked the performance to compare with glibc. I downloaded source for glibc with this command: apt-get source glibc I compare with following code. /glibc-2.19/string/strcpy.c #include and…
Amane
  • 3
  • 3
0
votes
1 answer

Testing void strcpy(char *s, char *t) in K&R

I'm testing the function void strcpy(char *s, char *t) I've just learned in K&R (page 106) but my codes (shown below) don't seem to work. Please help. Thanks a lot. PS: I've changed the name of the function to strcpy1 to differentiate it from the…
Nien Van
  • 9
  • 1
0
votes
2 answers

GDB does not give information about where and how a program attached to gdb failed. WSL

I have searched everywhere for how to fix this and I could not find anything, so I'm sorry if there is already a thread existing on this issue. Also, I'm fairly new to Linux, GDP, and StackOverflow, this is my first post. First, I am running on…
Zack Jorquera
  • 554
  • 7
  • 13
0
votes
2 answers

Strcpy() Segmentation Fault

I have created a function which searches each line of a file and tries to match the parameter par_string with a string in the file. I have variants of the function working for doubles and ints, but I can't seem to modify the function to read in…
Saultyevil
  • 55
  • 1
  • 4
0
votes
1 answer

Why does the C compiler allow me to use strcpy to overwrite string literal?

Why is the below code working in Visual Studio ? char* str1 = "This is a test string"; strcpy_s(str1, strlen(str1), "replacing content"); My understanding is str1 is just a char* pointing to a string literal, and not to an array of chars. And in…
TanM
  • 99
  • 1
  • 6
0
votes
1 answer

Appending to string as input argument

I am having trouble generating a string inside a C routine. Goal Have function generate a custom string and return the value e.g. 'void getName( char ** name )' Attempt int main(void) { char *name; getName(&name); } void getName(char…
J-Dizzle
  • 4,861
  • 4
  • 40
  • 50
0
votes
1 answer

How to copy array_src TO> destination_array, starting at certain index at destination? ( using strcpy() )

A struct node containing {... char opcode_CHAR[6]; } a pointer declared struct node *pointer2 pointing to a node of that struct kind; got a char temp_array[6]. j = 6 - sizeof(temp_array); So depending on the sizeof(temp_array), I will copy to a…
topcat
  • 177
  • 3
  • 17
0
votes
1 answer

strcpy_s copying more than string length to target buffer (filling with 0xFE)

I have the following C++ code: std::string test = "ABC"; char buffer[30]; for (int i = 0; i < 30; i++) buffer[i] = 0; strcpy_s(buffer, 30, test.c_str()); After running it, I expect buffer to be: [0x41, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, ...…
Mendes
  • 17,489
  • 35
  • 150
  • 263
0
votes
1 answer

Exception: Access violation writing location when using strcpy_s

When I compile the following code, I get this exception: Unhandled exception at 0x0FA8E90F (ucrtbased.dll) in console.exe: 0xC0000005: Access violation writing location 0xFFFFFFCD void test() { char *type = malloc(sizeof(char) * 256); …
0
votes
1 answer

char[] with duplicate value after strcpy

I have a struct with two char array variables(id and id_partner_expected) and when i use the strcpy on second array the first array is changed also. I tried everything i know, but without expected result :( #define SIZE_CLIENT_ID 15 struct…
Batels
  • 77
  • 1
  • 6