Playground
#include <iostream> #include <cstring> using namespace std; int main() { char a[] = "prva niza"; char b[] = "vtora niza"; char c[] = "tekst"; char d[] = "tekst"; cout << strlen(a) << endl; //pechati '9' cout << strlen(c) << endl; //pechati '5' char t[100]; strcpy(t, "Nekoja vrednost"); //t="Nekoja vrednost" strcpy(t, "Neshto drugo"); //t="Neshto drugo" strcpy(t, a); //t="prva niza" strncpy(t, b, 4); //t="vtor niza" (ne se kopira '\0') t[4] = '\0'; //t="vtor" strcat(t, b); //t="vtorvtora niza" cout << t << endl; //pechati 'vtorvtora niza' cout << strcmp(t, a) << endl; //pechati '1' cout << strcmp(c, d) << endl; //pechati '0' return 0; }
Input data
Program output
no input
Execute
Language: ????????? | Memory: ???? KB | Time: ??? ms
Nothing has been executed, yet!