Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:26:45+00:00 2026-06-11T16:26:45+00:00

void slice_first_char(char ** string) { *string = &(*string[1]); } int main(int argc, char *

  • 0
void slice_first_char(char ** string)
{
    *string = &(*string[1]);
}

int main(int argc, char * argv[])
{
    char * input = "abc";
    input = &(input[1]);
    puts(input); // "bc" as expected.

    slice_first_char(&input);
    puts(input); // \372\277_\377
                 // What‘s going on?
}

How can I rewrite a slice_first_char function to make it work as expected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:26:47+00:00Added an answer on June 11, 2026 at 4:26 pm

    You got the parentheses in

    &(*string[1]);
    

    wrong. I guess you meant

    &((*string)[1]);
    

    Your original version dereferences the pointer of the first element of the strings array, and then takes the address of that whereas you actually want to dereference the given pointer (because it just points to a single string), then take the first element of that (the first character) and then take the address of that.

    A slighty less convulated way to express this would be

    *string + 1
    

    by the way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

void test() { unsigned char c; c = (~0)>>1 ; printf(c is %u\n,c); }
- (void)TargetHit:(int)target{ void (^threadBlock)(void) = ^{ NSLog(@respond to selector %d, [self respondsToSelector:@selector(changeImageOfTarget:)]); [[NSOperationQueue mainQueue]
void foo(Node* p[], int size){ _uint64 arr_of_values[_MAX_THREADS]; for (int i=0 ; i < size
void say(char msg[]) { // using pointer to print out the first char of
void AFCQueue::ExtractValuesSecComplex(int startIndex, int endIndex,int helperIndex) { int size = 0,i,index; TimeType min_timestamp; bool
I am trying to use following code to perform few animations -(void) performSlidingfromX:(int) xx
private void mostrarDiapositiva(Vector<Diapositiva> d, int pos) { if ( pos >= d.size() ) {
- (void)viewDidLoad{ [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@VidName ofType:@mov]; NSURL *url =
- (void)connectionDidFinishLoading:(NSURLConnection *)connection { self.listFeedConnection = nil; // release our connection [UIApplication sharedApplication].networkActivityIndicatorVisible =
- (void)fadeOutSplash { UIImageView *splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@Default-Landscape~ipad.png]]; [self.window.rootViewController.view addSubview:splash]; // <--

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.