I want to read an amount of string from the file
Given inputfile.txt
Micheal
Tammy
Alex

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	FILE* input;
        char name[100];
	char temp[100];

	input = fopen("inputfile.txt", "r");
	while((fscanf(input,"%c ", &name[i]))==1)
	{
		printf("%c ", name[i]);
		temp[i] = name[i];
		i++;
	}
}

So what is your question?

Sorry my poor english.
Given a file named inputfile.txt
Inside got string
Michael
Tammy
Alex

I want to know the code how to read and print each name.
Mine now prints M i c h a e l T a m m y A l e x

I solve it already. Thanks for the concern.

Given inputfile.txt
Micheal
Tammy
Alex

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	FILE* input;
	int i=0;
	char name[100];

	input = fopen("inputfile.txt", "r");
	while((fscanf(input,"%s", name))==1)
	{
	printf("The first word in the file is %s\n", name);
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.