[ create a new paste ] login | about

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

C, pasted on Nov 24:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int STRLEN(char s[])
{
	int count = 0;
	while (s[count] != '\0')
	{
		count++;
	}
	return count;
}

void HoanVi(char &a, char &b)
{
	char Temp = a;
	a = b;
	b = Temp;
}

void STRREV(char s[])
{
	int length = STRLEN(s);
	for (int i = 0; i < length / 2; i++)
	{
		HoanVi(s[i], s[length - 1 - i]);
	}
}
int main()
{
	char str1[100];

    printf("Nhap chuoi: ");
	//scanf("%s",str2);
    gets(str1);  // phải dùng gets
	STRREV(str1);
	printf("\nDao chuoi: %s", str1);


	getch();
	return 0;
}


Output:
1
2
3
4
Line 17: error: conio.h: No such file or directory
Line 16: error: expected ';', ',' or ')' before '&' token
In function 'STRREV':
Line 26: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: