By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,431 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,431 IT Pros & Developers. It's quick & easy.

i want help in visual c++ code

P: 5
Consider the following code:
struct MyStructure
{
char MyString[40];
int MyInteger;
};

MyStructure StructVariable[20];
MyStructure *StructPointer;

StructPointer = StructVariable;

i. Does this code have any error(s)? If there correct it.
ii. Store some values (in member variables MyString and MyInteger) in 15th element of the array StructVariable using StructPointer.
Nov 8 '08 #1
Share this Question
Share on Google+
4 Replies


Banfa
Expert Mod 5K+
P: 8,916
i. What apart from the obvious that you have not put in a main function? The answer rather depends on whether you think you are writing C or C++ code. Have you tried to compile it? What did the compiler say?

ii. Thank you but with 20 years of programming experience I have no need to attempt such a simple exercise! I suggest you attempt the problem that way you may learn something, there is a fine article on arrays here.
Nov 8 '08 #2

Expert 10K+
P: 11,448
If there correct it.
You forgot to say the magic word; do it yourself it is your homework exercise
after all.

kind regards,

Jos
Nov 8 '08 #3

P: 5
i. What apart from the obvious that you have not put in a main function? The answer rather depends on whether you think you are writing C or C++ code. Have you tried to compile it? What did the compiler say?

ii. Thank you but with 20 years of programming experience I have no need to attempt such a simple exercise! I suggest you attempt the problem that way you may learn something, there is a fine article on arrays here.
thanks but i am not going to compile it i tried and get this solution please tel me is it correct or not
struct MyStructure
{
char MyString[40];
int MyInteger;
};

MyStructure Variable[14];
MyStructure * Variable Ptr;
MyStructure Variable = {"hello sir",50};
Nov 8 '08 #4

Expert 10K+
P: 11,448
We are not going to compile it for you either; did you try to compile it? What did
your compiler say about it? We are not a free compiling service nor are we a free
do-your-homework service.

kind regards,

Jos (moderator)
Nov 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.