#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
char *get_street_address(void); /*function prototype*/
int main(void) {
char *street_address = NULL;
street_address = get_street_address();
/*Check if the above state is successful if not the program is terminated*/
assert(street_address != NULL):
printf("The entered street address was: %s \n", street_address);
/*Return the memory block to the pool*/
free(street_address);
return 0;
}
/*Implement the function get_street_address(void)*/
char *get_street_address(void) {
/*Assign a memory of 150 characters to the "input" pointer*/
char *user_input = malloc(150);
/*Check if the memory assignment is successful*/
if (user_input == NULL) {
printf("Unable to assign memory!\n");
return NULL;
}
/*Ask for user_input*/
printf("Enter your street address: ");
scanf("%149s", user_input);
getchar();
return user_input;
}
Subscribe to:
Post Comments (Atom)
Mounting USB drives in Windows Subsystem for Linux
Windows Subsystem for Linux can use (mount): SD card USB drives CD drives (CDFS) Network drives UNC paths Local storage / drives Drives form...
-
I. Five different ways to answer a question II. Use SOLO strategies to explain our thinking and reasoning III. SOLO Taxono...
-
Learning levels 1, 2, and 3 Learning levels 4, 5, and 6 References http://www.cccs.edu/Docs/Foundation/SUN/QUESTIONS%20FOR%20TH...
No comments:
Post a Comment