[ create a new paste ] login | about

Link: http://codepad.org/KKdXvjD2    [ raw code | output | fork ]

C, pasted on Jun 29:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void print_string_loop(char*, int, int, int);
void character_change(char*, int);

int main(void)
{
    int i=0;
    int element_size = 10;
    int element_num = 2;
    char* main_pointer = malloc((element_size * element_num) * sizeof (char*));
    strcpy(main_pointer, "Epic");
    strcpy(main_pointer + element_size , "Failure");

print_string_loop(main_pointer, element_size, i, element_num);

printf("\n \n");

character_change(main_pointer, element_size);

print_string_loop(main_pointer, element_size, i, element_num);

printf("\n \n");

free(main_pointer);

return 0;
}

print_string_loop(char* main_pointer, int element_size, int i, int element_num)
{
        for(i=0;i<element_num;i++){
        printf("%s ", main_pointer + (element_size * i));
    }

}

character_change(char* main_pointer, int element_size)
{
    *(main_pointer + 3) = 'x';
    *(main_pointer + element_size + 3) = 'x';

}


Output:
1
2
3
4
Epic Failure 
 
Epix Faixure 
 


Create a new paste based on this one


Comments: