Left Operand Must Be l-Value

xiaoxiao2021-03-06  43

- Author:? Maimarco-- Published: 2004-11-1019: 51: 01-- wrong do not understand !!!! // sd.cpp: Defines the entry point for the console application.// # INCLUDE "stdafx.h" #include struct classd {char name [8]; int Age;}; int main (int Argc, char * argv []) {char bb [8]; classd class1; printf ("% s / n", "Please enter your name:"); scanf ("% s", & bb); class1.name = bb; // error message "'=': Left Operand Must Be l-Value "What reason return 0;}

- Author: nearwate-- Published: 2004-11-1021: 23: 59-- because classd is not the default data type, so you can not use that as an ordinary assignment = char type, can only use the strcpy function, class1. Name = bb; it should be changed to: strcpy (class1.name, bb); but you have to add a header file #include in the program head

转载请注明原文地址:https://www.9cbs.com/read-76433.html

New Post(0)