Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define size 20
- #define sizearr 8
- char* nthWrd(const char* ref, int n)
- {
- n--;
- char *p;
- char* countlet(char* object, int cntr)
- {
- char *res;
- while ( *(object) = '\0')
- {
- cntr++;
- }
- memcpy( res=(char*)calloc(cntr, sizeof(char)),ref,cntr );
- return res;
- }
- while (--n)
- {
- p = strchr(ref,(int)' ');
- }
- char *res = countlet(p,0);
- return res;
- }
- void main()
- {
- char* ref = "hello beautiful morning";
- char *res = nthWrd(ref,2);
- printf("%s\n", res);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement