Thread: having a problem here

  1. #1
    Registered User
    Join Date
    Nov 2006

    having a problem here

    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?

    // Compiler Includes
    #include <stdio.h> 
    #include <string.h>
    #include <stdlib.h>
    #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 ScanPersonByValue(void);	// function to scan person info
    void PrintPersonInfo (PERSON_TYPE personToPrint);
    int main (void) {
    	//local variable
    	PERSON_TYPE personOne = {"\0", "\0", "\0"};
    	personOne = ScanPersonByValue();
    	return 0;
    PERSON_TYPE ScanPersonByValue (void) {
        PERSON_TYPE inputPerson = {"\0", "\0", "\0" };
        //	char buff[MAX_ARRAY_SIZE] = {"\0"};
    		printf("\nenter your name:");
    		fgets( sizeof, 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("NAME: %s            \nADDRESS: %s       \nPHONE: %d\n",, 
             personToPrint.address, personToPrint.phoneNumber); // prints structures from PERSON_TYPE
    } // end function PrintPersonInfo

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You are missing a comma on the "fgets" lines.

    Use "MAX_PATH" for the size of filenames - 100 may be a bit short on some systems. (I do realize you're not using MAX_STRING_SIZE yet, but the comment says that it's the max size of filename).


  3. #3
    Registered User
    Join Date
    Nov 2006
    Thanks a bunch, figures it was something small like that!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM