about string

M

Michael Mair

what i do for putting a space in the string
for Example:
this is google group.

It is not clear what you want to do.
Do you want to "insert" something into a string?

E.g.
char buffer1[80] = "this is google group.";
becomes the same as
char buffer2[80] = "this is go ogle group.";

Cheers
Michael
 
B

Bill Pursell

what i do for putting a space in the string
for Example:
this is google group.


#include <stdlib.h>
#include <string.h>

int
main(void)
{
char a[] = "this is google group";
char *c;

/* Replace the first 'g' with a space. */
a[8] = ' ';

/* Replace the first 'o' with a space. */
c = strchr(a, 'o');
if (c != NULL)
*c = ' ';

/* Replace the first 's' with a space. */
for (c=a; *c && *c != 's'; c++)
;
if (*c)
*c = ' ';

/* Replace the final 'Z' with a space. */
c = strrchr(a, 'Z');
if (c != NULL)
*c = ' ';

return EXIT_SUCCESS;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top