i'm currently wanting to do this in C.

store the following into a giant string
"======================"
'\n'
"Month : "
st.month
"/n"
"Day : "
st.day
I could do this easily if i didnt have members of a structure that i need to obtain their value(they are bolded). How do i deal with them in order to combine all the strings, and the values of st.month and st.day so they get stored into the string as well? without these i know i could just easily concatenate ot store them alltogether at once!
example of output:

char buffer[500];
displaystring(&buffer)

display in command prompt:

======================
Month : 4
Day : 12

Recommended Answers

All 2 Replies

Look up sprintf() . That will allow you to put a string together from different variable types.

char buffer[500];
sprintf(buffer, "======================\nMonth : %d\n:Day : %d\n", st.month, st.day);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.