

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why we can't use arrow operator in gets and puts?
You can't read user input in an un-initialized pointer. Instead, have a variable of the struct data type and assign its address to pointer before accessing its inner elements by → operator
example
#include <stdio.h> struct example{ char name[20]; }; main(){ struct example *ptr; struct example e; puts("enter name"); gets(e.name); ptr=&e; puts(ptr->name); }
Output
Typical result of above code
enter name Disha You entered Disha
- Related Questions & Answers
- Why can't we use column name “desc” in MySQL?
- Why you shouldn't use a VPN?
- Why can't we upload multiple files anymore at Coding Ground?
- Why can't we define a static method in a Java interface?
- Why can't we use the "super" keyword is in a static method in java?
- Why do we use comma operator in C#?
- Why can't girls have all the fun?
- Why can't 'kotlin.Result' be used as a return type?
- Why we can't initialize static final variable in try/catch block in java?
- why Python can't define tuples in a function?
- Why can't static method be abstract in Java?
- Why can't a Java class be both abstract and final?
- Why can’t we override static methods in Java?
- How can I use 'Not Like' operator in MongoDB?
- Why can't Java generics be used for static methods?
Advertisements