1234567891011121314151617181920212223242526272829303132
#include <iostream> using namespace std; struct box{ char maker[40]; float height; float weight; float length; float volume; }; void display(box *); void display(box * b){ cout << b->maker << endl; cout << b->height << endl; cout << b->weight << endl; cout << b->length << endl; cout << b->volume << endl; } int main(){ box *b = new box; b->maker = "JoJo Adventure"; // i cannot assign string to array b->height = 60.5; b->weight = 103.4; b->length = 200.0; b->volume = 100; display(b); return 0; }
C++Dev.cpp:23: error: incompatible types in assignment of ‘const char [15]’ to ‘char [40]’
char maker[40];
std::string maker;
box b;