Common Mistakes : Scanf Errors
1 : Don't forget to write "&" before variable name
#include<stdio.h>
void main()
{
int num;
//Incorrect Way : scanf("%d",num);
scanf("%d",&num);
}- Syntactically it won't show any error message
- Logically It shows you "Garbage" or "Unexpected Value".
- "&" should be written before "Variable" name .
2 : Don't write "&" before Pointer variable
#include<stdio.h>
void main()
{
int num;
int *ptr;
ptr = #
//Incorrect Way : scanf("%d",ptr);
scanf("%d",ptr);
}- Pointer variable Stores address of variable where it points .
- "&" is used to access "Address of Variable" , therefor no need to write "&" before pointer variable .
- Pointer stores the address of another variable , it accesses variable directly.
Bookmark & Share
0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email