Click to See Complete Forum and Search --> : Array functions
zer0_flaw
Sep 1st, 2002, 11:51 AM
I'm using C... not C++. I need to know some of the basics about arrays. Fortunitly I already know how to declare, set, and use arrays but there is more I learned in other languages that I want to learn here. How do I return the number of items in an array, get the last item in an array (not using indexs to get it... using something like perl's "pop(@bleh)" function which returns the last item), how to add an item to the end of an array, etc. Any good array functions are welcome. Also, any tutorials about file handling would also be welcome. As you can guess, most tutorials only touch the basics of how to do each thing... I want to dig deeper. Thanks in advance!
-zer0 flaw
jim mcnamara
Sep 1st, 2002, 12:16 PM
None of what your requested -
array length
dynamic array insert
etc.
is available as a single library function in C. It is much more low-level than VB. You have to roll your own.
dynamic arrays require using malloc & realloc & pointers
Use sizeof() to find array length.
Most C programmers have a library of routines they lug around from place to place. Or know a site to download them from.
zer0_flaw
Sep 1st, 2002, 02:44 PM
I'm curious if this would work... all I want to do is add an item to the end of an array:
bleh = ("abc", "123", 13);
bleh = (bleh, "heh");
/* bleh now =s ("abc", "123", 13, "heh") */
If that doesn't work how do I go about this? Also, printing an array... besides looping through each item and printing the item each time, is there a quicker way (ex: printf("bleh") will print each item seperated by a space in perl).
Lastly, how do I get the 3rd, 4th, and 5th characters in a string? Other languages can do this... not sure about C. Sorry for the dumb newbie questions but I've read numerous tutorials on C now and still have much info to be obtained.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.