What's wrong with "char *p; *p = malloc(10);"?

Answer Posted / clay

Here,

After char *p;
since pointer p is not initialized it is pointing at some
unknown location.

In the next step, the address of the memory allocated by
malloc() is stored at some garbage location pointed by p.

Here p is never initialized or never assigned any value.

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scanf () in c?

666


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

1858


What is ambagious result in C? explain with an example.

2060


what is a constant pointer in C

684


How do you construct an increment statement or decrement statement in C?

747






How can you increase the size of a statically allocated array?

622


What are the main characteristics of c language describe the structure of ac program?

616


in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above

637


What are global variables and how do you declare them?

623


Why is python slower than c?

611


What is the difference between struct and typedef struct in c?

663


Write a program to find the biggest number of three numbers in c?

590


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1123


What are the rules for identifiers in c?

592


How can you check to see whether a symbol is defined?

596