int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
++zPtr;
// use pointer to get first value of array
number = zPtr;
// assign array element 2 (the value 3) to number
number = *zPtr[ 2 ];
// print entire array z
for ( int i = 0; i <= 5; i++ )
cout << zPtr[ i ] << endl;
// assign the value pointed to by sPtr to number
number = *sPtr;
++z;
char s[ 10 ];
cout << strncpy( s, "hello", 5 ) << endl;
char s[ 12 ];
strcpy( s, "Welcome Home");
if ( strcmp( string1, string2 ) )
cout << "The strings are equal" << endl;
homework, exam is same thing. We are not here to give you answers for your study. We are here to assist when you have legit programming problems.
I've looked back at your posts. Most of them have been blatent requests the same as this for answers. You've shown very little to no effort in trying to solve these problems yourself. Why should we give you the answers?
If you cont posting in this fashion, I'll make a recommendation to have your account removed.
it is problem .. what is the diffrent between my Q and legit programming problems?
Most people with legitimate problems will post the work they've done so far. They'll highlight an error in the code and the compiler message corresponding to it. From there we can read the compiler problem, or read their description of the problem, and come to a viable solution for them to try. They actually make some form of effort to solve the problem themselves first.
and I challenge u .. if u can find an error in #1;
Alot of the people who provide advice on these forums are professional developers. We've seen all the silly little assignment problems many times before so they are easily recognised by us. They also provide little to no challenge as the tasks are so trivial to solve.
qhen look at it u will understand why I ask ..
As I've just said. Such questions are very trivial to solve for professional developers. I myself can see 4 things I'd change in Q1 to make the code more robust, that'd depend obviously of the constraints on your assignment, as in a professional application I'd re-write it completely.
We are not here to solve your homework/assignment/exam questions for you though. We are here to help you solve them once you've made a viable effort to work through them.
So all n all. How about you try to solve them yourself first. We only help those who help themselves.