that is, getting 3 names like john,david and deny using "for" loop then storing these names into an array using the same "for" loop.
simply getting and storing names will be done in the same "for" loop in any method like without using pointers.i've a doubt is there any method to getting and storing names in "for" loop without using pointers?if so please explain me........
How can we store strings in an array in c?
You may want to buy K%26amp;R's "The C Programming Language" which is the standard book for C programmers. They cover C strings. I'll point you to an online tutorial (http://www.cprogramming.com/tutorial/c/l... ).
There's two ways you can have a string. You can either have a pointer to a string literal, or have an array (either a pointer to one or the array object itself).
You may want to lookup the C standard library to see what you can use for input. (http://cppreference.com/stdio/index.html... The fgets function is particularly useful for this. If you look at the tutorial I pointed you to, they mention how to use it.
Reply:You can do it with a fixed-size array of char* s:
char* MyArray[ 3 ];
But no, there have to be pointers involved.
lady palm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment