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

i have declared an array a[20]

P: n/a
a[20] and have scanned a name.
what will happen if all 20 memory allocations
arent used. i want to print the name in reverse.
will blank spaces be printed before the name??
Oct 13 '10 #1
Share this Question
Share on Google+
2 Replies

P: 17
It will print gargbage if you havent initialized it, you can also put some character that you want in the non used chars and with an if print everything skipping those chars.
Oct 13 '10 #2

Expert 100+
P: 2,398
I assume that you mean that your 20-element array contains a null-terminated string whose length is less than or equal to 19. To print this string backwards you need to find the character preceding the terminating null and then print each character from there back to the beginning of the array.
Oct 13 '10 #3

Post your reply

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