- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 7
- Posts with Upvotes
- 7
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
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). … | |
Re: [QUOTE=jared_masc;715783]ok i have changed it to this, but m gettin a warning "comparison between pointer and integer" [CODE] int getInputByscanf(char input[]){ char string[4]; int result; result = scanf("%c", &string); while (string != EOF) string = scanf("%c", &string); System("Pause"); return 0; } [/CODE][/QUOTE] You still haven't pointed out why you are … | |
Re: The upper limit of an int is 2147483647(32-bit system). When x reaches the value 1073741824, [icode]x<<1;[/icode] multiples that value by 2 which yields 2147483648 which is beyond the upper limit, hence the value goes in a circle and the number -2147483648 gets stored in x and consequently in m. since … | |
Re: [icode]b[j++]=((remainder-10)+'A');[/icode] This doesn't behave the way you want it to behave. I'm assuming that b[] is an array of integers. The above expression will only store ascii values of A,B,C,D,E,F. I suppose modifying your printf statement within the for loop will solve your problem. [code=c]for( j = count-1 ; j … | |
Re: [icode]string[i]=getchar();[/icode] I don't think this will work properly. getchar() expects you to hit enter after the input of each character which means that '\n' will be left in the input buffer which will be read the next time getchar() executes. Which means that each character will alternate with a '\n'. … | |
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 … | |
Re: Daniweb isn't a program spewing machine that you can command. | |
Re: On related topic, you may find [url=http://www.daniweb.com/forums/thread145177.html]this[/url] thread interesting. ArkM has explained floating pont conversions pretty well. | |
Re: 1. Construct two matrices. 2. Declare two 1-D arrays called rowAdd and colAdd to hold the values you obtain when you add the row and column elements respectively. 3. Once you find the sum of all the row elements and store it in rowAdd, see if the elements of rowAdd … | |
Re: Use int main(), indent your code, use switch cases and a while loop instead of goto and if cases. | |
Re: You gotta use code tags for people to consider answering to your post. Here's the syntax: [noparse][code=c] . . your code here . . [/code][/noparse] Anyway, just a cursory glance through your code showed a few big mistakes: 1. Use int main() 2. You are using %c to get a … | |
Re: There are quite a lot of mistakes in your program (still!). So instead of pointing out each and every of them, I just whipped up my own code and have offered explanations through comments. [CODE=c]#include <stdio.h> #include <conio.h> #include <string.h> int main() { char *loginID[] = {"user1", "user2", "user3"}; char … | |
Re: Your post gave me an adrenaline rush. Honestly!:icon_eek: | |
Re: You can also look up [url=http://en.wikipedia.org/wiki/RSA]RSA[/url] or [url=http://en.wikipedia.org/wiki/Data_Encryption_Standard]DES[/url] if you are dealing with delicate data. But they are both quite complicated to implement (compared to Caesar cipher and rot13). | |
Re: The if statement is wrong. It should be: [CODE=cpp]if (pow > 1) { full = num * full; return (power(num, --pow, full)); //You've already multiplied once. Don't do it again. }[/CODE] Also, your code breaks when pow = 0. Anyway, it's an easy thing to fix. | |
Re: As mentioned before, it makes more sense to make sure that the list is in order while inserting than to apply a sorting algorithm later. You can try this: [CODE=c]liste_t* Insert (liste_t *listptr, int val) { liste_t *lp = listptr; liste_t *prev = NULL; liste_t *info = (struct liste_t *) … | |
Re: [QUOTE]char dd[1];[/QUOTE] That's wrong. You're allocating memory for only one character. Should be dd[2]. [QUOTE]aa[] = dd[0] + dd[1];[/QUOTE] This statement adds the ASCII values of '2' and '3'. So your result will be 50(ASCII value of 2) + 51(ASCII value of 3). And the result can't be just assigned … | |
Re: Use code tags and indent your code properly. | |
Re: C language was developed by Dennis Ritchie, but I'm not sure if he's officially recognized as the 'Father of C language'. That said, don't post a thread as if you are at a gun-point. All those 'URGENT! URGENT! HURRY!' cries will only succeed in putting people off. Also search the … | |
Re: What's [icode]glblclrtab[/icode] pointing to? It'll have a NULL value or a garbage value which is causing segmentation fault. After you make it point to a character array, you can use [icode]*(glblclrtab+i)= (char) i1;[/icode] or [icode]glblclrtab[i]= (char) i1;[/icode] for simplicity. By the way, use code tags while posting your code. | |
Re: The algorithm in use is [url=http://en.wikipedia.org/wiki/Selection_sort]selection sort[/url][wikipedia.org]. It's one of the simplest sorting techniques. It's algorithm is: 1. Find the smallest element in an unsorted array. 2. Swap it with the value at the first position for the current iteration. 3. Repeat this procedure n-1 times. (n being the no … | |
| Re: The same program works fine in my compiler (code::blocks using GCC). It prints the line "Sum of all elements = %d" too. |
Re: Read the reply for your previous post and stop trolling around. | |
Re: After 8 posts, the community expects you to know how to use code tags. Click [url=http://www.daniweb.com/forums/thread93280.html]here[/url] | |
Re: It was already explained to you by Ancient Dragon in your [url=http://www.daniweb.com/forums/post759666-2.html]previous thread.[/url] | |
Re: Firstly, your indentation is pretty bad. I lost the flow at the middle of the code. Secondly, use int main(). I think this is wrong: [CODE]if ([COLOR="Red"]cMenu = 1[/COLOR]); // statment for if cMenu is true[/CODE] You are using an assignment operator instead of '==' operator. The else part of … | |
Re: You can use the [url=http://www.cplusplus.com/reference/clibrary/cassert/assert.html]reference[/url] if you aren't sure of how the assert function works. I think in your program, you've to "assert" that the value of the variable _inode stays within 0 to 3 and this has to be done in the for loop. If the value of that … | |
Re: [QUOTE]can you please just explain why you added [i] in those positions within the for loop, because when i replaced my original code with them, i got 4 errors, all the same.[/QUOTE] [icode]struct sale Weekly_Sale[13];[/icode] What you're doing here is creating a user-defined variable called Weekly_Sale of type 'struct sale'. … | |
Re: You're missing a semi-colon after defining the struct. Should be: [CODE]struct names{ // definitions ----- ---- ---- }[COLOR="Red"];[/COLOR][/CODE] | |
Re: I (and probably others too) don't fully understand your problem. How can the following be "working fine" for you? char * hex = (..dynamically allocated memory with malloc..); And you haven't explained your problem well enough, either. Here's what i understood it as: You have two character arrays-str1 and str2. … |