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
0 answers

String concatenates with another after strcpy for the latter

As you can see in my code bellow I don't mess with e[i].politico in the for cycle where my problem occurs, but for some reason, after perfoming a strcpy onto e[i].risco of a predifined char array, e[i].politico gets appended with e[i].risco's…
Gomes
  • 11
  • 2
0
votes
1 answer

using arrow operator to calculate average of 3 members of a structure, need to convert from dot operator to arrow

i am practicing c, and i just learned how to assign integers and create structures, i came across the arrow operator and i do not know how to apply it, i researched a little and i now know that a->b is the same as (*a).b and that arrow is used for…
0
votes
1 answer

strcpy makes pointer from integer without a cast

I am trying to insert a character at a specific position in the char array (char *peep) but every time I try, I get a strcpy error Current Code int main(){ char *peep = malloc(256); int pos; char character, charToStr[2]; …
user17067764
0
votes
2 answers

Efficient strcpy and move pointer to end of destination

I need to copy some c-like string to another and move its pointer. I wrote wrapper around strcpy that moves destination pointer and I'm wondering if there is some better way to do this. This is what I have done for now: #include #include…
Kamil
  • 13,363
  • 24
  • 88
  • 183
0
votes
1 answer

Properties of strcpy()

I have a global definition as following: #define globalstring "example1" typedef struct { char key[100]; char trail[10][100]; bson_value_t value; } ObjectInfo; typedef struct { ObjectInfo CurrentOrderInfoSet[5]; }…
user16921148
0
votes
1 answer

I have a problem when i'm printing char** array

I'm working with grap. My graph is a structure like this typedef struct{ int order; // number of node int **mat; // matrix graphe }graphe; I'm working on school project and I need to build a set of binary's number from 0 to N (where is the…
0
votes
2 answers

strcpy not working inside for loop? c programming

I am writing a program that loops through a text file with two columns. the first values are strings and the second are ints. I am trying to put them in arrays based on their column. Data example: stephen 170 shane 150 jake 180 Im trying to do…
Steve
  • 1
  • 1
0
votes
0 answers

Using Multithreading to write randomized Strings to a global pointer

I'm trying to learn a bit more about the properties about Threads in c++, more accurate: Posix Threads. I constructed a little program that let's you write a total number of string of certain length into a big char* cstr that holds all of the…
G3cko
  • 23
  • 5
0
votes
3 answers

Type of parameter accepted by strcpy() ?

Why is that strcpy() accepting char array pointer even though the definition of strcpy is char * strcpy( char * , const char * ) ?? #include #include main() { char str[] = "Have A Nice Day"; char ptr[17]; …
Rabi
  • 19
  • 2
0
votes
1 answer

C++ Buffer Overflow, strcpy, fgets, sprintf showing runtime error

#include #include #include int check_authentication(char* password) { int auth_flag = 0; char* password_buffer; char* dept; password_buffer = (char*)malloc(16); dept = (char*)malloc(10); …
0
votes
1 answer

OnlineGDB c++ not compiling strcpy_s

I'm going to compile a very simple code on onlinegdb.com The code is as below. #include #include int main() { char s[10] = {0}; strcpy_s(s, 10, "1234567890"); printf("%s", s); return 0; } I chose…
coding monster
  • 384
  • 4
  • 18
0
votes
1 answer

Edit char array in C, output cut off

First of all, I know that there are a lot of questions about this topic. But I have searched a lot and tested the solutions I found with similar issues but without success. I want to edit a char array when foo is called and another when bar is…
bac
  • 93
  • 1
  • 13
0
votes
2 answers

Why do i get this stack smashing error in my program?

I am practicing my use of strcpy() in C and wrote this program. #include #include int main(){ int array[4] = {3,7,1,5}; char str[4], temp[5]; for (int i = 0; i < 4; i++){ sprintf(&str[i],"%d", array[i]); …
0
votes
1 answer

strcpy() unusual behaviour in C

so I decided to test out how strcpy() works and while reading the Linux Programmer's Manual. I came across the definition of strcpy The strings may not overlap, and the destination string dest must be large enough to receive the copy. So from…
Areen
  • 21
  • 4
0
votes
2 answers

Conditional jump or move depends on uninitialised value(s) at strcpy

Valgrind detects a problem with strcpy in the following code: #include #include #include int main () { char **array; int mallocedLen = 15; int arrLen = 10; char tempArr[20][20] = {"abc", "123",…
V. Loh
  • 27
  • 5