- This topic has 3 replies, 2 voices, and was last updated 9 years, 8 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
|
Miscellaneous › Others › bugs in c programming
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf(“enter your name n “);
char name [74];
char person [74];
scanf(“%[^n]s”,name);// scanf can deal in this case with multi word
printf(“Hello %s! n “,name);
printf(“enter your name n “);
gets(person);
getchar();
puts(“hello “);
puts(person);// a run time problem
}
#include <stdlib.h>
int main()
{
printf(“enter your name n “);
( you have to define it just after main)
char name [74];
char person [74];
(in scanf you have to pass the address of variable like &name)
scanf(“%[^n]s”,name);// scanf can deal in this case with multi word
(use gets and puts for string operations)
printf(“Hello %s! n “,name);
printf(“enter your name n “);
gets(person);
getchar();
puts(“hello “);
puts(person);// a run time problem
}
thanks alot for such a rapid reply
(use gets and puts for string operations)
can you explain more
you have already used these functions
like
char name[30];
printf(“enter name”);
gets(name);
.
.
.
.
printf(“name of person is “);
puts(name);
i suggest for such basic programs refer good books on C language programming like “let us C”