Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #define ROW 8
- #define COLUMN 8
- int main()
- {
- char* test = "You are retarded!";
- char *newchar;
- int i;
- int k = 0;
- int nc;
- int copy_flag = 0;
- newchar = (char *)malloc(strlen(test));
- if (!newchar)
- {
- printf("Could not allocate memory!");
- exit(1);
- }
- for(nc = 0; nc < strlen(test); ++nc)
- {
- int loop = 0;
- if(test[nc] == ' ' && copy_flag == 1 && loop != 1)
- {
- //printf("flag is off\n");
- copy_flag = 0;
- loop = 1;
- }
- if(copy_flag == 1)
- {
- //printf("%c\n", test[nc]);
- newchar[k] = test[nc];
- k++;
- newchar[k] = '\0';
- }
- if(test[nc] == ' ' && copy_flag == 0 && loop != 1){
- //printf("flag is on\n");
- copy_flag = 1;
- loop = 1;
- }
- }
- printf(newchar);
- free(newchar);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement