-
Array & Strings Problem
hey there,
i need help on the following program.
I need a full explanation on what this code prints please
Code:
#include <stdio.h>
#include <string.h>
void f1(struct St1 *Ptr1);
void f2(struct St1 Ptr1);
struct St1
{
char arr[15];
char *ptr;
};
int main()
{
static char string[5][10] = {"Today","exam","is","very","fun"};
struct St1 st1Arr[3] = {{"Good", *string}, {"Luck", *(string+1)}, {"!!", &string[1][2]}};
struct St1* pSt1 = st1Arr;
printf("%s\n", (*pSt1++).arr);
printf("%s\n", (*++pSt1).ptr);
}
thanks in advance
-
Counter proposal:
You run it, and tell us
1) What the output is
and
2) What output you expected.
Put a little bit more time into it, and save us time explaining things you already know, or don't care about.
-
the output is:
good
am
and trust me if i did understand or didn't put time in it like you said i probably wouldn't ask for help and i do care on knowing how to analyze it since i have an exam on it
thanks again
-
Which part/line don't you understand?
The first word "good" should be easy, isn't it?
Bye, Andreas