3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by jnawrocki
-1
#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;	
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.