This is my first assignment using structs and I am having a minor syntax issue. I am currently trying to hard code the first six entries of an inventory into my program but cannot assign values to the strings of the struct. Heres the code:
It looks like you're writing in C and not C++, is that right?
In that case, use the strcpy function. strcpy(Catalog[0].Brand, "BrandName");
You'll also need to make sure the array is big enough to hold what you are copying in.
No, its c++. I was just about to delete the thread, I cannot believe I did not remember the string commands had to be used. Thank you for the quick reply though. I'm not sure why we are using structs instead of classes, is that why you asked about C/C++?
No, its c++. I was just about to delete the thread, I cannot believe I did not remember the string commands had to be used. Thank you for the quick reply though. I'm not sure why we are using structs instead of classes, is that why you asked about C/C++?
If it was C++ I would just use std::string instead of worrying about char arrays. Then just write Catalog[0].Brand = "BrandName";
You won't have to worry about size issues, either, among other things.