Answer:
See explaination
Explanation:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void oddsOnly(char* str)
{
int i;
for (i = 0;i < strlen(str);i++)
{
if(i%2 != 0)
{
str[i/2] = str[i];
}
}
str[i/2] = '\0';
}
char* mySubstring(char* string ,int beginIndex,int endIndex)
{
char* new_string = malloc(endIndex- beginIndex);
for (int i = beginIndex ;i < endIndex;i++)
{
new_string[i -beginIndex] = string[i];
}
new_string[endIndex] = '\0';
return new_string;
}
int main(void)
{
char str[] = "hello there";
oddsOnly(str);
char* str1 = mySubstring("smiles",1,5);
printf("%s\n",str);
printf("%s\n",str1);
}