Thread: missing header file...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305

    Question missing header file...

    Hi,

    I have been trying to run the program on visual studio c++ but it keeps giving me the error that alloc.h does not exist.
    Is it that the new compilers donot have some of the header files and/or i need to have some other decalaration for it?

    insert
    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <alloc.h>
    
    void main(){
    
    		
    	char *names[6];
    	char n[50];
    	char *p;
    	int i, len;
    	for(i=0;i<6;i++)
    		printf("\n\r%u", names[i]);
    
    	for(i  0;i< 6;i++){
    
    		printf("Enter the number");
    		scanf("%s",n);
    		len = strlen(n);
    		p = malloc(len+1);
    		strcpy(p,n);
    		names[i] = p;
    	}
    
    	for (i =0;i< 6;i++){
    		printf("%s", names[i]);
    	}
    
    
    	/*for(i=0;i<6;i++){
    	printf("Enter the names");
    	scanf("%s", names[i]);
    	}*/
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    What do you believe you need alloc.h for, if it existed? (Hint: malloc is in <stdlib.h>.)

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Probably for the same reason he thinks he needs conio.h.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Not to mention void main.

    @OP, whatever book you're reading, throw it away.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Salem View Post
    @OP, whatever book you're reading, throw it away.
    My money is on Schildt.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Jun 2009
    Location
    US of A
    Posts
    305

    Cool

    Hi,

    Thanks for pointing out the mistakes. :-)

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by quzah View Post
    My money is on Schildt.
    In which case Salem's recommendation definitely applies.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM