I'm reworking my URL decoder, the first step is to seperate out the input, I made this function up to read input, but the phone number is coming out wierd, I think its printing the address. Can anyone help me out here?
Code:#define _CRT_SECURE_NO_DEPRECATE // Compiler Includes #include <stdio.h> #include <string.h> #include <stdlib.h> //Constants #define MAX_STRING_LENGTH 100 // Maximum file name length #define MAX_ARRAY_SIZE 100 // maximum array size //User defined definitions typedef struct { // auto_type structure definition char name[MAX_ARRAY_SIZE]; char address[MAX_ARRAY_SIZE]; char phoneNumber[MAX_ARRAY_SIZE]; } PERSON_TYPE; PERSON_TYPE ScanPersonByValue(void); // function to scan person info void PrintPersonInfo (PERSON_TYPE personToPrint); int main (void) { //local variable PERSON_TYPE personOne = {"\0", "\0", "\0"}; PrintPersonInfo(personOne); personOne = ScanPersonByValue(); PrintPersonInfo(personOne); return 0; } PERSON_TYPE ScanPersonByValue (void) { PERSON_TYPE inputPerson = {"\0", "\0", "\0" }; // char buff[MAX_ARRAY_SIZE] = {"\0"}; printf("\nenter your name:"); fgets(inputPerson.name sizeof inputPerson.name, stdin); printf("\nenter your address:"); fgets(inputPerson.address sizeof inputPerson.address, stdin); printf("\nenter your phone number:"); fgets(inputPerson.phoneNumber sizeof inputPerson.phoneNumber, stdin); return inputPerson; } void PrintPersonInfo (PERSON_TYPE personToPrint) { printf("\n==================================================================\n"); printf("NAME: %s \nADDRESS: %s \nPHONE: %d\n",personToPrint.name, personToPrint.address, personToPrint.phoneNumber); // prints structures from PERSON_TYPE } // end function PrintPersonInfo



LinkBack URL
About LinkBacks


