コード例 #1
0
int main(int argc, char *argv[])
{
	FILE *fp = NULL;
	char *line=NULL;
	char str[256];
	size_t read;
	size_t len = 0;

	if(argc!=2)
	{
		exit(EXIT_FAILURE);
		printf("Invalid arguments\n");
	}

	fp = fopen(argv[1],"r");

	if(fp == NULL)
	{
		printf("ERROR: Couldn't open the file, please check\n");
		exit(EXIT_FAILURE);
	}
	while ((read = getline(&line, &len, fp)) != -1)
		{

			strcpy(str, line);
			int index =  firstNonRepeating(line);
			if (index == -1)
				printf("Invalid String");
			else
				printf("%c\n", str[index]);
		}
  return 0;
}
コード例 #2
0
ファイル: panagram.c プロジェクト: vnrk/Algorithms
/* Driver program to test above function */
int _panagram()
{
  char str[] = "We promptly judged antique ivory buckles for the next prize";
  firstNonRepeating(str);
  return 0;
}