Thread: Where is the error!

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    130

    Where is the error!

    I have these 2 simple codes that generate the same error message:

    Pointer2 error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup

    Pointer2 is the name of the project that the code1 exists
    For the second code (which is in another project) also generate the same message:

    The codes:

    Code:
    #include <stdio.h>
    
    
    void p2(){
    	char txt[20], *txtPtr;
    
    	printf("Enter txt: ");
    	scanf("%s",txt);
    	printf("\n\n");
    	txtPtr=&txt[0];
    
    	while(*txtPtr!=NULL){
    	printf("%c",*txtPtr);
    	txtPtr++;}
    }
    int main()
    {
    	//p2();
    	int i,sum,x[3],*p;
    	sum=0;
    	printf("Enter 4 numbers");
    	for(i=0; i<=3; i++){scanf("%d",&x[i]);}
    
    	p=&x[0];//3 -- 
    
    	while(*p!=0){
    	sum+=*p;
    	//printf("%d ",*p);
    	p++;}
    
    	printf("The sum %d",sum);
    }
    -----------------------------------------------------------

    Code:
    #include <stdio.h>
    
    int max2(int h[3]);
    void showMax();
    int m;
    
    int main()
    {
    	int i,x[3];
    	printf("Enter four numbers:");
    	for(i=0; i<=3; i++){
    		scanf("%d",&x[i]);}
    	m=max2(x);
    	showMax();
    
    }
    
    int max2(int h[3]){
    	int i;
    	int maxSofar1;
    	maxSofar1= h[0];
    	for(i=0; i<=2; i++){
    		if(h[i]>maxSofar1)
    			maxSofar1=h[i];}
    	return maxSofar1;
    }
    
    void showMax(){
    	printf("The max: %d",m);
    }

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    You've set up your project as a GUI application, but provided console application code. Set up your project as a console application -- sometimes the easiest way to do this is just to make a new project from scratch and add your source file(s).
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    130
    Thanks alot; it is working now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM