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

int main()
{

	int i;
	char line[100];
	char line2[100];
	

	printf("Enter some lines : ");
	scanf("%[^\n]",line);
	printf("2:");
	scanf("%[^\n]",line2);

	if((i = strlen(line)) >= 80)
	{
		printf("%s",line);
	}
	if(strlen(line2) >= 80)
	{
		printf("%s",line2);
	}
	getchar();
	return(0);
}

the main aim of making this program is that it will input 2 lines and output only that line that is 80 or more in length.

errors :-
1. There is no compile error.
2. the second scanf(); function does not inputs.
3. No printf funtion occurs.

help me run this program successfully.

thanks in advance.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jonsca
0

Hehe. You must have an address operator inside the scanf();

scanf("%[^\n",&line]

Same with line2.

Try it.

0

Give this thread a read. It goes into the specifics of why using scanf in the manner that you have isn't a good idea. Use fgets instead. Simple syntax: fgets(line,sizeof(line),stdin);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.