Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "my_string.h"
- int main(int argc, char* argv[])
- {
- MY_STRING hMy_string = NULL;
- hMy_string = my_string_init_c_string("james carney");
- printf("james carney\n");
- //pushes
- if(my_string_push_back(hMy_string, ' '))
- {
- if(my_string_push_back(hMy_string, 'j'))
- {
- if(my_string_push_back(hMy_string, 'a'))
- {
- printf("%s\n", my_string_c_str(hMy_string));
- printf("size: %d\ncapacity: %d\n", my_string_get_size(hMy_string), my_string_get_capacity(hMy_string));
- printf("pushing successful\n");
- }
- }
- }
- //pops
- if(my_string_pop_back(hMy_string))
- {
- if(my_string_pop_back(hMy_string))
- {
- if(my_string_pop_back(hMy_string))
- {
- printf("%s\n", my_string_c_str(hMy_string));
- printf("size: %d\ncapacity: %d\n", my_string_get_size(hMy_string), my_string_get_capacity(hMy_string));
- printf("popping successful\n");
- }
- }
- }
- printf("the char at index 3, 5, 6 of 'james carney' are: %c, %c, %c\n",
- *my_string_at(hMy_string, 3), *my_string_at(hMy_string, 5), *my_string_at(hMy_string,6));
- MY_STRING other_string = NULL;
- other_string = my_string_init_c_string("mclean");
- printf("%s\n", my_string_c_str(other_string));
- if(my_string_concat(hMy_string, other_string))
- {
- printf("'james carney' and 'mclean' make %s\n", my_string_c_str(hMy_string));
- }
- if(!my_string_empty(other_string))
- printf("the string is not empty\n");
- while(my_string_get_size(other_string) != 0)
- {
- if(!my_string_pop_back(other_string))
- {
- printf("cant empty string by popping\n");
- break;
- }
- }
- if(my_string_empty(other_string))
- printf("the string is empty\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement