strcpy Questions
3
Solved
#include <stdio.h>
#include <string.h>
int main()
{
char src[]="123456";
strcpy(src, &src[1]);
printf("Final copied string : %s\n", src);
}
When I use the Visual Studio 6 Comp...
4
Solved
My understanding is as follows:
char * points to a string constant, modifying the data it points to is undefined. You can, however, change where it points to.
char[] refers to a block of memory t...
2
Solved
Is memcpy() usually faster than strcpy() (on most real platforms)? (I assume that size of the string is known.)
If I remember i386 assembler correctly, there are loop instructions which copy a giv...
Benzvi asked 26/7, 2014 at 1:42
3
Solved
I am a beginner, and I am learning how to copy a string in C now.
Here is a problem I just met:
Every time I try to use "strcpy" command to copy from string 1 to string 2, Visual Studio 201...
17
Some people seem to think that C's strcpy() function is bad or evil. While I admit that it's usually better to use strncpy() in order to avoid buffer overflows, the following (an implementation of ...
7
Solved
6
Solved
Background:
I have a small routine that mimics fgets(character, 2, fp) except it takes a character from a string instead of a stream. newBuff is dynamically allocated string passed as a parameter a...
2
I have a question about using strcpy. I know the ANSI C standard says : source and destination must not overlap, otherwise the behaviour is unpredictable. I show you a piece of code that works as I...
3
Solved
I am wondering why am I getting segmentation fault in the below code.
int main(void)
{
char str[100]="My name is Vutukuri";
char *str_old,*str_new;
str_old=str;
strcpy(str_new,str_old);...
Grandeur asked 26/4, 2012 at 2:53
4
Solved
I am writing to a binary file using a struct that just contains a char[32]. I basically need to format each block of data by performing various calculations on string arrays and concatenating the r...
4
Solved
The second arg in the prototypes for memmove/memcpy/strcpy are similar:
For example:
void *memmove(void *dest, const void *src, size_t n); //const void*
char *strcpy(char *dest, const char *src); ...
3
Solved
hello I have a code like the one below
char *str ;
strcpy(str, "\t<");
strcat(str, time);
strcat(str, ">[");
strcat(str, user);
strcat(str, "]");
strcat(str, "(");
strcat(str, baseNa...
2
I have a character array defined as follows: char *c[20];
I'm trying to do: strcpy(c[k], "undefined); but it's not working
I've also tried defining it as char c[20][70] with no luck.
Edit: I actu...
5
Solved
Why does the below C code using strcpy work just fine for me? I tried to make it fail in two ways:
1) I tried strcpy from a string literal into allocated memory that was too small to contain it. I...
4
Solved
I know that you will rap me over the knuckles but.
Why does it make Segmentation fault
char* cmd;
strcpy(cmd, argv[0]);
when this doesn't
char *cmd;
cmd = "plop";
I didn't practice since a w...
Gabbard asked 22/6, 2011 at 23:31
3
Solved
I have a global structure:
struct thread_data{
char *incall[10];
int syscall arg_no;
int client_socket;
};
and in main()
char buffer[256];
char *incall[10];
struct thread_data arg_to_thread;...
6
I'm perplexed as to why the following doesn't work:
char * f = "abcdef";
strcpy(f, "abcdef");
printf("%s",f);
char s[] = "ddd";
strcpy(&s[0], "eee");
printf("%s", s);
In both examples strcp...
6
Solved
Is it safe to do something like the following?
#include <stdio.h>
#include <malloc.h>
#include <string.h>
int main(void)
{
char* msg;
strcpy(msg, "Hello World!!!"); //<---...
5
Solved
Does a string created with 'strcpy' need to be freed? And how to free it?
Edit: The destination is allocated like this:
char* buffer[LEN];
4
Solved
In C i used strcpy to make a deep copy of a string, but is it still 'fine' to use strcpy in C++ or are there better alternatives which i should use instead ?
1
Solved
What would be the best way to copy unsigned char array to another?
For example:
unsigned char q[1000];
unsigned char p[1000];
strcpy (q,&p);
The above code does not work, it gives me error...
Bestir asked 22/12, 2010 at 7:56
9
Following is the most popular implementation of strcpy in traditional systems. Why dest and src are not checked for NULL in the start? I heard once that in old days the memory was limited so short ...
7
Solved
I am trying to understand the difference/disadvantages of strcpy and strncpy.
Can somebody please help:
void main()
{
char src[] = "this is a long string";
char dest[5];
strcpy(dest,src) ;
prin...
Hare asked 21/10, 2009 at 15:53
9
Solved
The first example does not work when you go to delete the pointer. The program either hangs when I add the null terminator or without it I get:
Debug Assertion Failed Expression: _BLOCK_TYPE_IS_VA...
7
Solved
The clue is in the title but basically I've inherited some code which has 800+ instances of strcpy. I want to write a new function and then to replace strcpy with strcpy_mine.
So I'm trying to work...
© 2022 - 2024 — McMap. All rights reserved.