Thread: Breaking out of a loop

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    Breaking out of a loop

    I'm just confused to think of a simple method to do this but

    Code:
    while (1) {
    
              length = recvfrom(s, buffer, BUF_SIZE, 0, NULL, NULL);
    
               if (eh->h_proto == ETH_P_NULL && memcmp( (const void*)eh->h_dest, (const void*)src_mac, ETH_MAC_LEN) == 0 ) {
    			/* Comparing the Ethertype*/
    			if(memcmp((void*)(etherhead+14), FCoe,2) == 0 || memcmp((void*)(etherhead+14),FIP,2) == 0){
    				Ethfrm->ptr = (struct FCfrm_t *)(&Ethfrm->pad);  // Ethfrm pointer 
    			} else if(memcmp((void*)(etherhead+14), VLAN,2) == 0){
    				Ethfrm->ptr = (struct FCfrm_t *)(&Ethfrm->reserved);
    				printf("VLAN HEADER\n");
    				if((etherhead[16]& 0x10) == 0x10){
    					//printf("readint %02X \n",etherhead[16]);
    					printEthfrm(Ethfrm);
    					//break;
    				}
    			} else {
    				printEthfrm(Ethfrm);
    				//break;
    			}
    		
    			/* Setting the FCframe_t StructureStart Pointer to the EthernetFrame*/
    			Ethfrm->ptr->StructureStart = Ethfrm;
                           ....
    			.....
    			....
                 }
    }
    Everytime i break i break out of the while loop but I want to break out of the if statement with the true arguement and I'm kinda not sure how to do it simply without just overdoing it.
    Last edited by kiros88; 09-01-2009 at 11:42 AM. Reason: Sorry rather just put the real code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fgets and breaking out of while loop
    By pollypocket4eva in forum C Programming
    Replies: 25
    Last Post: 01-05-2009, 06:50 PM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. A somewhat bizzare problem!!! - WHILE LOOP
    By bobthebullet990 in forum C Programming
    Replies: 3
    Last Post: 03-31-2006, 07:19 AM
  4. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM
  5. Breaking out of a loop
    By escarrina in forum C Programming
    Replies: 9
    Last Post: 04-05-2004, 12:05 PM