lvalue error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • t priya
    New Member
    • Jan 2012
    • 1

    lvalue error

    in this program
    #include<iostre am.h>
    #include<conio. h>
    void main
    {
    char c;
    c=="success";
    getch();
    }
    here, i got lvalue error in c=="success"
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    1. Are you sure you want == instead of =?
    2. c is a character and "success" is a string.

    Comment

    • mbahsakaw
      New Member
      • Jan 2012
      • 1

      #3
      Here some codes to sharpen your Algorithm ->

      Code:
      #include<iostream.h>
      #include<windows>
      
      int main()
      {
      int i;
      char c[1];
      cout << "Insert String's Length [number ] : ";
      cin >> i;
      
      c[1] = c[i];
      cout << "Insert a string : ";
      cin >> c;
      cout << c;
      
      cout << "\n\n";
      system ("pause");
      }

      Comment

      • Rashi Verma
        New Member
        • Jan 2012
        • 1

        #4
        i think that it will give an lvalue error and it may give u lack cast error becoz it`s string and u r assigning it to just character rather then array of characters....

        Comment

        • sumera
          New Member
          • Jan 2012
          • 2

          #5
          Originally posted by Rashi Verma
          i think that it will give an lvalue error and it may give u lack cast error becoz it`s string and u r assigning it to just character rather then array of characters....
          ....its because the main function misses paranthesis

          Comment

          • sumera
            New Member
            • Jan 2012
            • 2

            #6
            its because main func misses () and a string is being assigned to a char

            Comment

            Working...