Home > Back-end >  The problems in the computer level 2 C, strives for the big help
The problems in the computer level 2 C, strives for the big help

Time:11-10



I write a code for the programming, the general idea is to make a copy of a string to b, the number of leading asterisk,
Recycling loop will be assigned to the characters a, b b will be displayed after running uninitialized, check after the book is not found,



Note: the environment is a Microsoft Visual c + + 2010 Express, the header file. Only the stdio h
Thank you

CodePudding user response:

Make a copy of a string to b, the need to assign b a section of memory, but not allocate memory statements in your code,

CodePudding user response:

Character arrays and character pointer is different, you want to dynamically allocated a string length + 1 character array to operation,

CodePudding user response:

A little bit more simple:
Void fun (char * a)
{
Char * p=a;

While (* p=='*') p++;
While (* p) * +=* p++;
While (a & lt; P) * +='*';
}

CodePudding user response:

reference 3 floor early play play nuclear response:
a little bit more simple:
Void fun (char * a)
{
Char * p=a;

While (* p=='*') p++;
While (* p) * +=* p++;
While (a & lt; P) * +='*';
}


This concise, this from moving forward after don't need another array,

CodePudding user response:

reference 1/f, the frog studio reply:
make a copy of a string to b, the need to assign b a section of memory, but not allocate memory statements in your code,

Header file does not have stdlib. H there is no way to dynamically allocated memory, can only use the simple way?

CodePudding user response:

reference 5 floor read this reply:
Quote: 1/f, reference the frog studio reply:
make a copy of a string to b, the need to assign b a section of memory, but not allocate memory statements in your code,

Header file does not have stdlib. H there is no way to dynamically allocated memory, can only use the simple way?

If really could not allocate memory, 3/f is probably the most appropriate answer,
  • Related