Sunteți pe pagina 1din 4

Funcia C++ strcpy copiaz un ir de caractere surs n alt ir de caractere, destinaie.

Sintaxa ei
este:
view source
print?

1.char * strcpy(char * dest, const char * src );

n documentaia C++ este precizat c aceast funcie are un comportament impredictibil dac
irurile src i dest se suprapun.

Cu toate acestea, a devenit o practic uzual tergerea unor caractere dintr-un ir cu un apel de
forma: strcpy(s + i, s + i + 1); (pentru tergerea caracterului de indice i din irul s). Numeroase
soluii ale problemelor cu iruri de caractere de pe pbInfo.ro, inclusiv soluii oficiale, folosesc
aceast metod pentru eliminarea unor caractere dintr-un ir, metod care a funcionat n
versiunile mai vechi ale compilatorului GCC, dar nu mai funcioneaz n versiunea curent.

Recomandm tuturor utilizatorilor s evite eliminarea caracterelor dintr-un ir prin metoda


descris mai sus. O metod alternativ, care funcioneaz corect, utilizeaz un ir de caractere
suplimentar, astfel:
view source
print?

1.char s[256], t[256];


2....
3.//eliminam caracterul de indice i din s
4.strcpy(t, s + i + 1);
5.strcpy(s + i, t);

Functii ( siruri de caractere) permise la evaluator

Functions
Character classification
Defined in header <ctype.h>

checks if a character is alphanumeric


isalnum
(function)

checks if a character is alphabetic


isalpha
(function)

checks if a character is lowercase


islower
(function)

checks if a character is an uppercase character


isupper
(function)

checks if a character is a digit


isdigit
(function)

checks if a character is a hexadecimal character


isxdigit
(function)

checks if a character is a control character


iscntrl
(function)
checks if a character is a graphical character
isgraph
(function)

checks if a character is a space character


isspace
(function)

isblank checks if a character is a blank character


(C99) (function)

checks if a character is a printing character


isprint
(function)

checks if a character is a punctuation character


ispunct
(function)
Character manipulation

converts a character to lowercase


tolower
(function)

toupper converts a character to uppercase

Conversions to numeric formats


Defined in header <stdlib.h>

converts a byte string to a floating-point value


atof
(function)

atoiatolatoll converts a byte string to an integer value


(C99) (function)

strtolstrtoll converts a byte string to an integer value


(C99) (function)

strtoulstrtoull converts a byte string to an unsigned integer value


(C99) (function)

strtofstrtodstrtold converts a byte string to a floating point value


(C99)(C99) (function)
Defined in header <inttypes.h>

strtoimaxstrtoumax converts a byte string to intmax_t or uintmax_t


(C99)(C99) (function)
String manipulation
Defined in header <string.h>

strcpystrcpy_s copies one string to another


(C11) (function)

strncpystrncpy_s copies a certain amount of characters from one string to another


(C11) (function)

strcatstrcat_s concatenates two strings


(C11) (function)

strncatstrncat_s concatenates a certain amount of characters of two strings


(C11) (function)

strxfrm transform a string so that strcmp would produce the same result as
strcoll
(function)
String examination
Defined in header <string.h>

strlenstrnlen_s returns the length of a given string


(C11) (function)

compares two strings


strcmp
(function)

compares a certain amount of characters of two strings


strncmp
(function)

compares two strings in accordance to the current locale


strcoll
(function)

finds the first occurrence of a character


strchr
(function)

finds the last occurrence of a character


strrchr
(function)

returns the length of the maximum initial segment that consists


strspn of only the characters found in another byte string
(function)

returns the length of the maximum initial segment that consists


strcspn of only the characters not found in another byte string
(function)

finds the first location of any character in one string, in another string
strpbrk
(function)

finds the first occurrence of a substring of characters


strstr
(function)

strtokstrtok_s finds the next token in a byte string


(C11) (function)
Character array manipulation
Defined in header <string.h>

searches an array for the first occurrence of a character


memchr
(function)

compares two buffers


memcmp
(function)

memsetmemset_s fills a buffer with a character


(C11) (function)

memcpymemcpy_s copies one buffer to another


(C11) (function)

memmovememmove_s moves one buffer to another


(C11) (function)

Miscellaneous
Defined in header <string.h>
strerrorstrerror_sstrerrorlen_s returns a text version of a given error code
(C11)(C11) (function)

References
References
C11 standard (ISO/IEC 9899:2011):
7.4 Character handling <ctype.h> (p: 200-204)
7.8 Format conversion of integer types <inttypes.h> (p: 217-220)
7.22 General utilities <stdlib.h> (p: 340-360)
7.24 String handling <string.h> (p: 362-372)
7.31.2 Character handling <ctype.h> (p: 455)
7.31.5 Format conversion of integer types <inttypes.h> (p: 455)
7.31.12 General utilities <stdlib.h> (p: 456)
7.31.13 String handling <string.h> (p: 456)
K.3.6 General utilities <stdlib.h> (p: 604=613)
K.3.7 String handling <string.h> (p: 614-623)
C99 standard (ISO/IEC 9899:1999):
7.4 Character handling <ctype.h> (p: 181-185)
7.8 Format conversion of integer types <inttypes.h> (p: 198-201)
7.20 General utilities <stdlib.h> (p: 306-324)
7.21 String handling <string.h> (p: 325-334)
7.26.2 Character handling <ctype.h> (p: 401)
7.26.4 Format conversion of integer types <inttypes.h> (p: 401)
7.26.10 General utilities <stdlib.h> (p: 402)
7.26.11 String handling <string.h> (p: 402)
4.3 CHARACTER HANDLING <ctype.h>
4.10 GENERAL UTILITIES <stdlib.h>
4.11 STRING HANDLING <string.h>
4.13.2 Character handling <ctype.h>
4.13.7 General utilities <stdlib.h>
4.13.8 String handling <string.h>

Deci fara strrev, strupr, strlwr si ce-o mai lipsi de-acolo

http://en.cppreference.com/w/c/string/byte