Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Create a struct that holds the information for a house including at a
- * minimum the street, number, city, and zip code. Create 10 of these.
- * Sort them any way you would like and print them sorted.*/
- #include <stdio.h>
- #include <string.h>
- typedef struct {
- char Street[52];
- char City[32];
- char Zip[6];
- char Phone[20];
- } HouseInfo;
- HouseInfo Instances[10];
- char* GetLine (char* String, size_t Length) {
- char* StringPtr = fgets (String, Length, stdin);
- if (StringPtr != NULL) {
- size_t Last = strlen (String) - 1;
- if (String[Last] == '\n') {
- String[Last] = '\0';
- }
- }
- return StringPtr; //returns a pointer to the string
- }
- char* LoadStreet (HouseInfo Instances[]) {
- printf("Enter Street: \n");
- char* StreetPtr = GetLine(Instances->Street, sizeof(Instances->Street));
- return (StreetPtr);
- }
- char* LoadCity (HouseInfo Instances[]) {
- printf("Enter Street: \n");
- char* CityPtr = GetLine(Instances->City, sizeof(Instances->City));
- return (CityPtr);
- }
- char* LoadZip (HouseInfo Instances[]) {
- printf("Enter Street: \n");
- char* ZipPtr = GetLine(Instances->Zip, sizeof(Instances->Zip));
- return (ZipPtr);
- }
- char* LoadPhone (HouseInfo Instances[]) {
- printf("Enter Street: \n");
- char* PhonePtr = GetLine(Instances->Phone, sizeof(Instances->Phone));
- return (PhonePtr);
- }
- void LoadStruct (HouseInfo Instances[]) {
- }
- void Sort (int Zip) {
- }
- int main (void) {
- for (int i = 0; i < 10; i++) {
- LoadStreet(Instances[i]);
- }
- for ( int i = 0; i < 10; i++) {
- puts(Instances[i].Street);
- //puts(Instances[i].City);
- //puts(Instances[i].Zip);
- //puts(Instances[i].Phone);
- }
- return 0;
- }
- // Compiler Output pasted below... //
- ample.c: In function ‘main’:
- Sample.c:68:7: error: incompatible type for argument 1 of ‘LoadStreet’
- Sample.c:30:7: note: expected ‘struct HouseInfo *’ but argument is of type ‘HouseInfo’
Add Comment
Please, Sign In to add comment