[EMAIL PROTECTED] wrote:
Ummmm ...
Coding 3.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *
somefunction()
{
char *string2 = "some words";
return string2;
}
int main (void)
{
char *string;
string = somefunction();
printf ("\n\nString is: %s\n\n", string);
return 0;
}
somefunction returns string2 which is trash!
formally: The scope of string2 does not extend to main!
string2 is the return value of
char * somefunction which is extern ( or GLOBAL).
(even if it works, and it might, it's WRONG)
Moral of the story is don't code in C ;);) Or if you do use as many tools
to help you as possible. -Wall, and a C linter are a good start.
Valgrind is also meant to be good, although I haven't
used it.
If you're going to drive a sports car, learn to use the clutch!
He's learning. For sleek and mean there is no better (than C), but it does
require care and diciplin
This is totally trivial. What has driving sportscar to do with coding in
C ? What sportscar
do you drive ?
James
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html