- 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
83 Posted Topics
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. … | |
Re: Use code tags for your code [noparse][code=c] . . . Your code here . . . [/code][/noparse] | |
Re: Here's a useful [url=http://www.java2s.com/Code/C/Development/Howtochecktheperformancedifftime.htm]link[/url] | |
Re: Better use fscanf() to read integers. If you use fgetc(), you'll be reading the ascii values of the integers and not their actual values. Also every digit will be treated as a character. How will you read multiple-digit numbers then? Also you've used [icode]n = fgetc(fin)[/icode]. Is that what you … | |
Re: [QUOTE]My issue is that don't know how to keep prompting the user until the sentence is ended with a period. [/QUOTE] This is all you have to do to prompt the user till he enters a string with a period: [CODE=c] char msg[50]; int length = 0; do { printf("Enter … | |
Re: [QUOTE=yuvaraj.tr;736435]for(i=0;i<5;i++) { for(j=0;j<=i;j++) { printf("*\n"); } }[/QUOTE] That doesn't do any good. [QUOTE=Demonisya ]Create a program that could show this output * *** **** ****** [/QUOTE] Are you sure about the output? 1st row should have 1 asterisk, 2nd row should have 3, 3rd should have 4 and 4th row … | |
Re: Correct way of using code tags: [noparse][code=c] . . Your code here . . [/code][/noparse] | |
Re: [QUOTE=Salem;748556] Not to mention, the unindented code which is simply awful to look at.[/QUOTE] Second that. Also, flow of the code is confusing which is really awful considering the simplicity of the problem. main returns an integer. So it's [icode]int main()[/icode] not just [icode]main(void)[/icode]. This test condition is wrong: [code]else … | |
Re: More info [url= http://www.cprogramming.com/tutorial/random.html]here[/url] and [url=http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx]here[/url]. | |
Re: [url]http://www.cprogramming.com/tutorial/random.html[/url] | |
Re: Appending a new employee to the should be easy. Declare a few "templates"(poor choice of word, perhaps) of string such as: [code=c] char empInfoTemp[] = "Employee "; char nameTemp[]= " Name : "; . . .[/code] Now prompt the user for employee information and get that using fgets(). Then use … | |
Re: Read the doubles from the file in this way: [code=c]while(fscanf(input,"%lf", &x[N]) == 1)[/code] Even the previous code should work. Dunno why it crashed on your system. Also there's no error proofing in your code. What if there aren't 5 entries in the file? You gotta display a suitable error msg. … | |
Re: You declare a pointer within a function if you're gonna use it only within the function. If you wanna pass arguments to the function whose value you want processed within the function then you pass their addresses. In your ex, you're passing grade1 and grade2's addresses since you're processing them … | |
Re: [QUOTE]this one has me stumped, I'm not even sure where to begin[/QUOTE] You've listed the whole algorithm necessary for solving both the programs. There isn't much left to think about. Anyway, your decrypt function looks something like this: [CODE=c]void decrypt(char input[]) { char output[20]; int i; for(i=0; input[i]!='\0';i++) // without … | |
Re: You declare it as an integer. Ex: [CODE]int hex = 0xBCD; printf("%x",hex);[/CODE] | |
Re: This is your 14th post, and you still don't bother to use code tags. Also it was mentioned quite a lot of times in your [url=http://www.daniweb.com/forums/thread154910.html]previous thread[/url] that you should use [icode]int main[/icode] instead of [icode]void main[/icode]. | |
Re: 1. [B]struct num[/B], not strunct 2. If compiling in C, then [icode]struct num n1; struct num* p;[/icode] 3. [icode]p = &n1[/icode] | |
Re: MNTABPTR is only a pointer whose size is 4 bytes(32-bit system). What you want is to allocate memory for the size of the structure MNT which is 132 bytes. For which you either do this: [CODE]newnode = (MNTABPTR)malloc(sizeof(*newnode));[/CODE] or this: [CODE]newnode = (MNTABPTR)malloc(sizeof(MNT));[/CODE] | |
Re: [QUOTE=Ezzaral;741583]The hate mail section is the best.[/QUOTE] Yeah, that was a real hoot. :) | |
Re: Also, in C, shouldn't [icode]node *x;[/icode] be [ICODE]struct node *x;[/ICODE]? Another note - main returns int. | |
Re: malloc() always returns a void pointer. You need to typecast it. [icode]students = (struct student**)malloc(sizeof(struct student));[/icode] |
The End.