Ajinkyanaik 0 Newbie Poster
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.
Good. Now try
AA
ABCCBA
ABCDEEDCBA
#include <stdio.h>
#include <stdlib.h>
#include <String.h>
void DropMiddle2(char *Orig, char *New);
void DropBlanks(char *Str);
void main()
{
char Number[9],NewNumber[9];
strcpy(Number, "12344321");
printf("Orig %s\n",Number);
for(int x = 0; x <3; ++x)
{
DropMiddle2(Number,NewNumber);
printf("%s\n",NewNumber);
DropBlanks(NewNumber);
strcpy(Number,NewNumber);
}
}
void DropMiddle2(char *Orig, char *New)
{
int lengthorig = strlen(Orig);
int lengthnew = lengthorig/2;
int x;
for(x=0; x < lengthnew-1; ++x)
{
New[x] = Orig[x];
}
New[x++]= ' ';
New[x++]=' ';
for(;x<lengthorig;++x)
{
New[x] = Orig[x];
}
New[x] = 0;
}
void DropBlanks(char *Str)
{
int length = strlen(Str);
int x=0;
int y=0;
for(int z=0;z < 2; ++z)
{
while (Str[x] != ' ' && x < length)
{
Str[y++] = Str[x++];
}
x += 2;
}
Str[y] = 0;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.