Monday, November 29, 2021

StrCpy Implementation

 #include<stdio.h>
void fncpy(char* str2, char* str1) {
    int i = 0;
    while(*str1 != '\0') {
        str2[i] = *str1;
        i++;
        str1++;
    }
    *str1 = '\n'; //Isse lagana padega qki compiler khud ye copy nahi kareaga
    printf("Content from str2 to str1 is %s", str2);
}
int main() {
    char str1[5] = "atul";
    char str2[5];
    fncpy(str2, str1);
    return 0;
}

No comments:

Post a Comment

Priority queue deleting elements after ascending inputs Gaand Fadd

 using namespace std; #include<iostream> #define N 5 class pq { public:     int* arr;     int front;     int rear;     pq() {         ...