[ create a new paste ] login | about

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

C, pasted on Dec 8:
#include <stdio.h>
#include <stdlib.h>

#define FIR 10
#define NUM 80

void inp(char *s,int i);
void oup1(char *s);
void oup2(char *s);

int main()
{
	char *ch[NUM];
	char **s;
	int i,j;

	s=ch;

	printf("please write code\n");

	for(i=0;i<FIR;i++){
		inp(*(s)+i,i);
		
	}

	/*first loop*/
	for(i=0;i<FIR;i++){
		oup1(*(s)+i);
	}

	printf("\n");

	/*second loop*/
	for(i=0;i<FIR;i++){
		printf("%2d: ",i+1);
		oup2(*(s)+i);
	printf("\n");
	}
	return 0;
}

void inp(char *s,int i)
{
	char f[NUM];

	printf("%2d: ",i+1);
	gets(f);
	s=f;
}

void oup1(char *s)
{
	int i;
	char ch;

	for(i=0;i<NUM;i++){

		ch=*(s+i);
			if(ch==0)break;
		ch--;
		*(s+i)=ch;		
	}
}
void oup2(char *s)
{
	int i;
	char ch;

	for(i=0;i<NUM;i++){

		ch=*(s+i);
			if(ch==0)break;
		ch--;
		printf("%c",ch);		
	}
}


Output:
1
Segmentation fault


Create a new paste based on this one


Comments: