why cant we use strcat without initialing first parameter?
e.g.
char *b = "a";
char *a;
strcat(a,b);

MSDN says about strcat:
char *strcat( char *strDestination, const char *strSource );
Parameters
strDestination
Null-terminated destination string

strSource
Null-terminated source string

In your case pointer a is unitialized and does not point to null-terminated string.

> why cant we use strcat without initialing first parameter?
Because the first parameter is the array that strcat writes to. It can't be an uninitialized pointer because you have to own the memory that the pointer points to and it can't be a pointer to a string literal because string literals are read-only.

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.