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

No instance of overloaded function "strcpy_s" matches the argument list

For some reason a char cant go in strcopy_s();... #include #include using namespace std; struct DATE { int year; int month; int date; }; struct Book { char name[50]; char author[50]; int id; DATE…
amanuel2
  • 4,508
  • 4
  • 36
  • 67
0
votes
1 answer

Is strcpy_s part of the C++ Standard? Or only part of MS Visual C++

Using the function strcpy in MS Visual Studio gives me an error saying I should use strcpy_s which is safer to use. Is strcpy_s part of the C++ standard? Or is it only part of Microsoft Visual C++? Will code containing strcpy_s only compile in…
Jorge Luque
  • 435
  • 1
  • 4
  • 17
0
votes
5 answers

strcpy after strtok segmentfault in C

char test[10]="ab cd"; char* save=NULL; save = strtok(test," "); printf("%s\n",save); result : ab First, above code works very well. Next, I tryed to excute this code. but, segmentfault occurs. char test[10]="ab cd"; char* save=NULL; char*…
J. hs
  • 11
0
votes
1 answer

Why am I receiving this strcpy assignment error if the two variables I am assigning to each other are both of type string?

I'm getting this error: error: cannot convert 'std::string {aka std::basic_string}' to 'char*' for argument '1' to 'char* strcpy(char*, const char*)' Which I assume means it is unable to assign my one title string to my newtitle string,…
Dante
  • 59
  • 2
  • 10
0
votes
4 answers

strcpy in a struct gives SIGABRT

I'm currently working on an FTP client written in C, and it's working pretty good. I was successful in writing a function that connects to an FTP server and logs in with a username and password, but I'm having a problem returning errors. I have…
v1Axvw
  • 3,054
  • 3
  • 26
  • 40
0
votes
3 answers

How does structure array copying work in C?

This is the code that I want to run in C. #include #include main() { struct record { char name[2]; char letter; }; struct record student[10]; strcpy(student[0].name,"t");//copy "t" to first…
user5987642
0
votes
2 answers

Reproduce the behaviour of strcpy

I'm trying to reproduce the behaviour of strcpy in c, my problem is that the function works but it append extra stuff at the end. char *ft_strcpy(char * dst, const char * src) { int i; i = 0; while (src[i] != '\0') { dst[i] = src[i]; …
user5870683
0
votes
1 answer

Memory exception while trying to append char pointer to a fixed string

I have a requirement where I have to get the RFID RSSI value which is an int and convert it to a char pointer and append to it. Below is how I did it. char *epcBytes = (char *)tag_operation_report->tag.epc.bytes; int rssiString =…
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
0
votes
2 answers

strcpy in C does not copy properly to overwrite a string

I am trying to implement a infix to postfix conversion program in C. I wrote (cleanExpression) the following function to remove unwanted space in the given infix string expression. #include #include #include…
siva82kb
  • 1,910
  • 4
  • 19
  • 28
0
votes
1 answer

Strcpy and Strcat garbage chars

I have 2 strings: 'name1' and 'name2'. name1 is always of type something.inp and I want name 2 to be of type something.pts. so if name1 is 'data.inp', i wanted name2 to be 'data.pts'. I tried doing the following, but with no success, since when I…
Rui Loureiro
  • 119
  • 9
0
votes
1 answer

Program crashes after perfoming strcpy() function

I need some help with an assignement I have to do for school which consists in sorting some books after the title,author and the publication date of it. All the infos are given as a string in a txt file using a delimiter between them. The problem is…
0
votes
3 answers

passing argument 2 of strcpy makes pointer from integer without a cast

this is the whole code of what im doing, im trying to create a song library that will put what the user enter into file. now the compiler says that passing argument 2 of strcpy makes pointer from integer without a cast and i dont know why. also can…
shiiranyan
  • 15
  • 7
0
votes
2 answers

strncpy and strcat garbage characters in C

I tried to write a programme which copies the first k char from a string s1 and then concatenates the result with the rest of string s2 starting from a position i then concatenates the rest of s1 in the result. Yet I had some problems with…
programmer
  • 39
  • 7
0
votes
3 answers

STRCPY is undefined c++

Im attempting to implement strcpy or strncpy and both are showing an error no matter which i use. The error is only under strncpy and strcpy Item.cpp: #include "Item.h" #include #include #include #include using…
Andrew Barsoom
  • 81
  • 1
  • 3
  • 7
0
votes
3 answers

Writing replacement for strcpy

I have to write a replacement for strcpy without using pointers or the function having a return value... How could this be done?! this is what i have so far but it uses return values. void str_copy(char destination [], char source []) { int i; …