Skip to content

The following code does not work as intended. Chapter 8-Practice Set Question Number 4 #5

Open
@srivastavHimanshu4503

Description

@srivastavHimanshu4503

#include <stdio.h>

char* slice(char str[], int m, int n){
int i=0, count;
char *ptr1 = &str[m];
char *ptr2 = &str[n];

str = ptr1;
str[n] = '\0';
return str;

}
int main(){
char str[] = "Himanshu Srivastav";

printf("%s", slice(str, 6, 11));
// Desired Output : hu Sri
// Actual output: hu Srivasta (Wrong)
return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions