//-------------------------------------------------------------------------------------------------- void Test::testExceptionSpecification03() { std::set_unexpected(myunexpected); try { myfunction(); } catch (int) { std::cerr << "caught int\n"; } catch (...) { std::cerr << "caught some other exception type\n"; } }
int main (void) { int a; a = myfunction (); here: return a; }
int main(int argc, char * argv[]) { printf("Running %s\n",argv[0]); int * nbr; int mynbr=104; nbr=&mynbr; printf("Number is %d, return is %d\n",*nbr,myfunction(nbr)); return EXIT_SUCCESS; // equivalent to returning 0 // return EXIT_FAILURE ; // equivalent to returning 1 }
int main() { counter++; printf("Printing from main: %d\n", counter); myfunction(); counter++; printf("Printing from main: %d\n", counter); printf("\n\n"); system("PAUSE"); return 0; }
/* functions can take parameters... */ void myotherfunction(int n) { int i; for (i = 0; i < n; i++) /* Here, myotherfunction calls myfunction. */ myfunction(); printf("myotherfunction\n"); /* or just return; to leave a void function. */ return; }
int main(){ /*variable declaration*/ int i; float f; double d; char c; char string[] = "Hello World\n"; int rv; struct datastruct ds1; struct datastruct ds2; /*initialization*/ i=2+3; f=3.14159; d=3.14159; c='t'; ds1.age=33; strcpy(ds1.name,"John Doe"); ds1.c = 'z'; ds2.age = 43; strcpy(ds2.name,"Chin Zhou"); ds2.c = 'g'; printf("The value of i is %d\n",i); printf("The value of f is %f\n",f); printf("The value of d is %f\n",d); printf("The value of c is %c\n",c); printf("The value of string is %s",string); printf("structure age: %d\n",ds1.age); printf("structure name: %s\n",ds1.name); printf("structure c: %c\n",ds1.c); rv = myfunction(ds1,ds2); int j; //just have to decrare variables before you use them for(j=0; j<10; j=j+2){ printf("the index is: %d\n",j); } int k; k=0; while(k <20){ printf("current value of k is: %d\n",k); k+=5; } simpleFunction(&ds1,&ds2); printf("Location of ds1: %p\n",&ds1); printf("Location of ds2: %p\n",&ds2); return 0; }
int main (void) { int i, j; /* Call the test function repeatedly, enough times for all our tests without running forever if something goes wrong. */ for (i = 0, j = 0; i < 1000; ++i) j += myfunction (0); my_unique_function_name (j); return myfunction2 (j); }
/* * main is a special function which is the first thing * called by the OS when your program starts. */ int main() { printf("main!\n"); /* here, main calls myfunction... */ myfunction(); /* and then calls myotherfunction. */ myotherfunction(5); /* main is not a void function, but a function returning * an int, so we return 0. */ z = 5; printf("z = %d\n", z); return 0; }
int main() { int length; length = myfunction("Hello","Hi","Hey!",(char *)0);//the last 0 is to notice taht no more arguments.. printf("%d",length); return(0); }
int main() { int length; length = myfunction("Hello","Hi","Hey!",(char *)NULL); return(0); }
int main() { myfunction("My Custom Argument String"); myfunction(17); return 0; }
void CheckMeRound2(void){ myfunction(count); if(GETSWITCH1) count++; }
int main(void) { // Configure the device for maximum performance but do not change the PBDIV // Given the options, this function will change the flash wait states, RAM // wait state and enable prefetch cache but will not change the PBDIV. // The PBDIV value is already set via the pragma FPBDIV option above.. SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); // Auto-configure the PIC32 for optimum performance at the specified operating frequency. SYSTEMConfigPerformance(SYS_FREQ); // osc source, PLL multipler value, PLL postscaler , RC divisor OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_20, OSC_PLL_POST_1, OSC_FRC_POST_1); // Configure the PB bus to run at 1/4 the CPU frequency OSCSetPBDIV(OSC_PB_DIV_4); // Enable multi-vector interrupts INTEnableSystemMultiVectoredInt(); INTEnableInterrupts(); // Set up the UART peripheral so we can send serial data. UARTConfigure(UART_USED, UART_ENABLE_PINS_TX_RX_ONLY); UARTSetFifoMode(UART_USED, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY); UARTSetLineControl(UART_USED, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1); UARTSetDataRate(UART_USED, F_PB, UART_BAUD_RATE); UARTEnable(UART_USED, UART_ENABLE | UART_TX); // And configure printf/scanf to use the correct UART. if (UART_USED == UART1) { __XC_UART = 1; } // Enable LED outputs 0-7 by setting TRISE register TRISECLR = 0x00FF; // Initialize the PORTE to 0 PORTECLR = 0x00FF; // Set the lowest bit int mask = 1; PORTESET = mask; // Loop forever, it is bad to exit in an embedded processor. int count=0; // move this into the delay function while (1) { // Move this printf into your getDelay function! printf("Hello, world! %d\n",count++); // Replace this with the getDelay function call! int delay = 0x80000; //int delay = getDelay(); myfunction(); // do nothing for a lot of cycles int i=0; for(i=0;i<delay;i++) ; // shift left by 1 mask = mask << 1; // rotate around if more than 8 bits if (mask & 0x0100) mask = 1; // Set the output to the new mask PORTE=mask; } }
int main() { foo a = myfunction(); }