[ create a new paste ] login | about

Link: http://codepad.org/IdsRwFzH    [ raw code | output | fork ]

C, pasted on Jul 12:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void nhap(char*a)
{
	printf("\n nani:");
	gets(a);
}
//xóa n kí tự từ vị trí k
void dell(char*s, int vt)
{
	for (int i = vt + 1; i < strlen(s); i++)
	{
		s[i - 1] = s[i];
	}
	s[strlen(s) - 1] = '\0';
}
char*dellkitu(char*s, int vt, int n)
{
	int dem = 0;
	int dai = strlen(s);
	for (int i = vt; i <dai; i++)
	{
		dell(s, i);
		i--;
		dai--;
		dem++;
		if (dem == n)
		{
			break;
		}
	}
	return s;
}

//.chèn chuỗi a[30] vào vị trí k của chuỗi b[]
void add(char*s, int vt, char pt)
{
	int n = strlen(s);
	for (int i = n; i > vt; i--)
	{
		s[i + 1] = s[i];
	}
        s[i]=pt;
}
char*addpt(char*s, int vt, char *p)
{
	
	int n = strlen(p);
	for (int i = 0; i < n; i++)
	{
	      add(s,vt,p[i]);
	}
        return s;
}
int main()
{
	char s[100];
	char p[30];
	int m = strlen(p);
	nhap(p);
	fflush(stdin);
	nhap(s);
	//printf("\n chuoi duoc tra ve sau khi xoa n ki tu:%s",dellkitu(s,2,5));
	printf("\n chuoi add :%s", addpt(s,2, p));
	getch();
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
Line 17: error: conio.h: No such file or directory
In function 'dell':
Line 12: error: 'for' loop initial declaration used outside C99 mode
In function 'dellkitu':
Line 22: error: 'for' loop initial declaration used outside C99 mode
In function 'add':
Line 40: error: 'for' loop initial declaration used outside C99 mode
In function 'addpt':
Line 50: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: