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 8459077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:14:56+00:00 2026-06-10T13:14:56+00:00

I have this code: char *name[] = { a1, b2, c3, d4 }; printf(%s\n,

  • 0

I have this code:


     char *name[] = { "a1", "b2", "c3", "d4" };
     printf("%s\n", *name); //the critical line

Related to critical line:

In this form, the output is simple: a1.
If I replace the critical line with:

printf("%s\n", ++*name);

then the output is 1. I think until now everything is good.

Taking in account that name is a pointer to the first string of characters, respectively "a1", I replace the critical line with:

printf("%s\n", ++name);

in the hope that I’ll get "b2" result as output. But I get this error:

../src/test.c:32: error: lvalue required as increment operand.

Question: I can’t understand why ++*name is legal – name is a pointer to first string of characters – and ++name isn’t. In my opinion, the ++name should move the name to the next string of characters. Can anybody explain me where is the lack in my understing?

  • 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-10T13:14:58+00:00Added an answer on June 10, 2026 at 1:14 pm

    When you write ++name, the array name is converted to a pointer to the first element of the array. The result of this conversion is not an lvalue, and it can’t be modified with ++ or otherwise. You could instead write name+1, which would print the right thing. When name is an array, there is no way to modify it to refer to anything other than that array[*].

    Consider also:

    char **p = name;   // OK, `name' converts to pointer
    ++p;               // OK, `p' is an lvalue
    ++(p+1);           // not OK, `p+1' is not an lvalue
    ++((char**)p);     // not OK, `(char**)p' is not an lvalue
    
    ++*name;           // OK, `*name' is an lvalue
    

    Roughly speaking, an “lvalue” is an expression that refers to an object, whereas a “not an lvalue” is an expression that has a value. The difference between an object and a value, is that an object is a place for storing values (well, one value at a time). Values can never be modified, objects sometimes can.

    Whenever you have a subexpression which is an lvalue but whose current value is needed, the object is read/loaded/whatever you want to call it. In C++ this is called an “lvalue to rvalue conversion”, I can’t remember whether it’s called anything in C other than “evaluating the subexpression”.

    [*] you can shadow it with another variable name in an inner scope, that refers to something else. But that’s still not modifying the outer name, just temporarily hiding it.

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

Sidebar

Related Questions

I have this code struct Student { char name[48]; float grade; int marks[10,5]; char
I have this code in C (it's for study only): char x; uint64_t total
String product = Integer.toString(w); char[] original = String.toCharArray(product); This is the code I have
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
When I run this code: #include <stdio.h> typedef struct _Food { char name [128];
i have implement this code from programming pearls and i think it should be
I have written this simple c code in microsoft visual c++ 2010. #include<stdio.h> #include<conio.h>
I have this code encrypting my file: static const char* KEY = Test; ...
I have some code that outputs like this: void exec_prompt(char * usr_name, char *
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2

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.