Copying Array to Another Array

Monday, October 12, 2009

This code will explain You how to copy from one array to another array..

#include<stdio.h>
#define MAKS 30

int main(void){
    int i;
    char asal[] = "I like C...";
    char hasil[MAKS];

    i = 0;
    while(asal[i] != '\0'){
        hasil[i] = asal[i];
        i++;
    }

    hasil[i] = '\0'; // give null char
    printf("Content of hasil: %s\n", hasil);

    //return 0;
}


This is the result.




0 comments:

Post a Comment

 
 
Copyright © Welcome