I'm using the following swap function to swap two elements of an array. The element pointed to by 'x' and 'y' and the one right below it, to be particular (then i want x and y to point to the second of the swapped elements, hence i use auto increment). I use the following call in the main function to call the swap function: [CODE=C]swap(&a[x][y], &a[++x][y]);[/CODE] And the swap function looks like this. [CODE=C]void swap(int* p, int* q) { int temp; temp = *p; *p = *q; *q = temp; return; }[/CODE] I dunno where i've gone wrong- is it …

Member Avatar
Member Avatar
+0 forum 3

Hi, I'm trying to call a bunch of methods during run-time using reflection, but I'm getting an exception saying "IllegalArgumentException: wrong number of arguments". Here's some information on the variables used. - All elements of mailTestClass[] are classes that extend AbstractTestCase. (FirstTestCase extends AbstractTestCase and FirstTestCase.class is the first element of mailTestClass) - These classes have constructors which take a String as an argument. - After instantiating a class, init(Object[][] args) method is called using reflection. The part of the code which creates the objects using reflection works fine. The code blows up when the method init(Object[][] args) is called. …

Member Avatar
Member Avatar
+0 forum 2

I found the following code in the 'Code snippets' section( written by nanodano). i tried compiling it in my Dev-Cpp compiler, and i got the output as shown in the attachment for up, left, down and right arrow keys respectively. All other defined keys i.e., F1 to F10 gave the proper output-although F11, F12, PageUp, Page Down, Home and End gave similar output as the arrow keys. Also i didn't understand why we have to use getch() twice. Can someone explain, please? [CODE=C] /* This program shows how to pick up the scan codes from a keyboard */ /* These …

Member Avatar
Member Avatar
+0 forum 9

[CODE=C]#include<stdio.h> #include<conio.h> int main() { float a=0.7; if(a<0.7) printf("C"); else printf("C++"); getch(); return 0; }[/CODE] The above code prints 'C'. Whereas the following two codes prints 'C++'. Why is that? [CODE=C]#include<stdio.h> #include<conio.h> int main() { float a=0.7; if(a>0.7) printf("C"); else printf("C++"); getch(); return 0; }[/CODE] [CODE=C]#include<stdio.h> #include<conio.h> int main() { float a=0.7; if(a<0.7f) printf("C"); else printf("C++"); getch(); return 0; }[/CODE]

Member Avatar
Member Avatar
+0 forum 10

I have tried to come up with a 2-D (4 rows and 4 columns) array which holds values from 0 to 15, with none of the values used more than once. I'm posting only the code snippet. please lemme know if the logic is correct. [CODE=C] int HIGH=16; /*(Max value of an array element)+1*/ int done[15]; /* Shows which of the 16 numbers have already been used*/ int i, j, val; time_t secs; time(&secs); /*assign 'secs' with the current time*/ srand((unsigned)secs); /*initialize the seed for rand()*/ for(i=0;i<15;i++) done[i]=0; /* None of the 16 numbers have been used yet*/ for(i=0;i<4;) { …

Member Avatar
Member Avatar
+0 forum 7

The End.