519 Posted Topics
Re: Also where is value for the variable emp on line 7 coming from ? | |
Re: @aranath In the code sample that you have given, it is possible that more than 1 enemy may be present in the sample spot. Also you want to use srand to randomize the order in which the random numbers are generated :) @GamerXXX is it fine if 2 enemies appear … | |
Re: In the accept data function, write a bunch of cin statements and when the user enters the data, write all of it to the file. | |
Re: Well the lines array just has space to store the contests of the file. It does not have space to store the header. Secondly in C if you want to assign a string constant to an char array you want to do something of this sort char arr[]="This is a … | |
Re: Or some thing of this sort [CODE]int main() { int a,b,c; scanf("%d\n%d\n%d",&a,&b,&c); printf("A is %d\nB is %d\nC is %d\n",a,b,c); return 1; } [/CODE] PS: Using scanf is a bad idea. The sooner you shift to fgets the better | |
Re: I saw this same question on this forum a couple of days ago ... Go thru the postings on this forum for last 2-3 days .... | |
Re: An easy way would be to execute the ls command in your program... | |
Re: Print the value of the file descriptor. When I printed the value I got -1. One reason could be, as the article mentioned that I am unable to open the file due to lack of permissions. Have you taken care of this issue ? | |
Re: When you are checking to see how many chars have been printed via fprint use the condition <=0 insteaad of < 0 | |
Re: Generating random strings as a whole is tough ... You could chose a random length and then chose random chars to fill that length | |
Re: In your scenario when ever the sender is sending some data, the last 2 chars will always be '\r' and the '\n'. So if I wanted to send ABC across the stream then I will send it across like this "ABC\r\n" In the receive function the code is reading the … | |
Re: Towards the end of your while loop(lines 83-84) you ask the user to chose between y/n but the variable that you have used for taking the input is an integer. So what happens is when the user enters y, scanf sees that it has received an char but the variable … | |
Re: Suppose x contains the id number that you are looking for [CODE]ptr= list; for(i=0;i<list->count;i++) { // If you find a match then break; // Else do nothing } if(i==list->size) // this means we went through the entire list and did not find a match[/CODE] | |
Re: WaltP's approach is much much more simpler .... | |
Re: What exactly is the problem ? When you say nothing is happening its really not that descriptive .... Are you able to open the input/output files ? Are you getting garbage o/p ? Are you getting compile time/ run time errors ? The more detail that you give about the … | |
Re: I normally use fread to read from a file. But I am surprised to see none of you mentioned that method. Are there any known pitfalls in using fread ? | |
Re: Probably you could use a switch statement ???? [url]http://msdn.microsoft.com/en-us/library/66k51h7a%28VS.80%29.aspx[/url] | |
Re: Tell me some thing why are combinations like [B]bcanm[/B] allowed ? PS: I dont think you have spent any time working on your algorithm | |
Re: @nbaztec Are you actually recommending gets over fgets ? | |
Re: Dont use getment(). Use malloc instead to allocate memory. Google for the syntax of malloc | |
Re: Open file 1 Open file 2 Read a string of n chars from file1 into array1 Read a string of n chars from file 2 into aray2 Compare array1 and array2. You will have to ignore spaces and new lines when you are trying to comapre | |
Re: You have to make the parent wait for the child to die before killing itself. A simple solution will be to use wait(NULL) in the parent Now the parent waits for the child to die before terminating [CODE] int main() { int pid; pid = fork(); if (pid) { printf("I'm … | |
Re: There is a logical error in your code. Check to see what code I have written and you will spot the error. [CODE]mult1=1; for(i=n;i<=m;i++) //loop till the m { mult=1; for(j=1;j<=i;j++)// for factorial { mult=mult*j; } mult1=mult1*mult; }[/CODE] PS: Avoid using scanf. It has lots of hidden problems. Shift to … | |
Re: What is the objective of your program ? Are you supposed to read from a file, do some processing on the string and send the string across ? If yes then I think you are over complicating a simple program ? | |
Re: You probably want to say [CODE]while(cAns=='y'||cAns=='Y') {}[/CODE] Also I think the expansion of while(cAns=='y'||'Y') should be while((cAns=='y')||'Y') which will always be true | |
Re: When you create a file check the file handler to see if it is not null. Also I dont like the fact that you have forked thrice in the main program. When you call fork() you create an additional process.So after the first call to fork is executed there will … | |
Re: I dont agree with the logic of your + operator. I would do something of this sort [CODE]while(A.top!=NULL && B.top!=NULL) { sum= (A.top)->data + (B.top)->data; Z.push(sum); } while(A.top!=NULL) Z.push((A.top)->data); while(B.top!=NULL) Z.push((B.top)->data); [/CODE] So if the input is 123+ 50, you will have some thing of this sort Stack 1: 1,2,3 … | |
Re: Switch can only accept integers and chars not strings. Get rid of the nested loops, you dont need so much complication for such a simple program You the program flow suggested by nbaztec | |
Re: Check out this link [url]http://forums.macosxhints.com/showthread.php?t=2023[/url] I think this should solve your problem | |
Re: The problem is when you code of the sort [CODE]int i; printf("Enter val "); scanf("%d",&i);[/CODE] and you input the value 5, you are actually pressing 2 keys 5 and the enter key. The value 5 gets assigned to i but enter key is still present in the stream. Then in … | |
Re: What have you got so far ? Are you a CS student ?And you are trying to get other people to do your programming assignment | |
Re: Yes I think you are correct. But I advise you to cement your understanding by using some example. For instance if I have the data 10,20,15, how will the code handle it ? | |
Re: Can you be more specific of what kind of help do you need ? Are there compile time errors, run time errors or do you need help to design the algorithm ? | |
Re: Do you know how to create a binary tree ? It is the same principle, but instead of 2 children now you have 5 children. Also does the problem state any restrictions on how you have to insert the node ? In the sense does the tree have to be … | |
Re: Around a week ago..some one posted a very similar question and it was answered (debated) in much detail. Just search for the question in the C forum | |
Re: Your main function contains a while loop in which you check for which selection is made. But you do not increment the value of i. So if I were to chose option a 5 times, it will enter data in prson[0] only. | |
Re: In addition to what has been suggested above, I would advise you to run the for loop from 0.....strlen(word) as opposed to 0....20 | |
Re: I node a similar question in one of the more recent posts. Did your question get solved there ? | |
Re: The problem is in the winsock library. When you call functions from that library, you get linker error. Write a simple 2-3 line code calling a function from winsock library to check if your library is installed correctly | |
Re: There are 2 solutions to your problem. First which I believe is the more simpler one. Here you are dealing with a single pointer which points to the beginning of the array [CODE]int* test2 (int arr2[][4],int mul){ for (int i=0;i<2;i++){ for(int j=0;j<4;j++){ arr2[i][j]=arr2[i][j]*mul; } } return &arr2[0][0];//sending back the address … | |
Re: find return a pointer to the location of the first =. Then copy the contents from after the = till end of string into a temporary buffer Return the temporary buffer | |
Re: Can you post how you have declared taMsgOut ? | |
Re: [QUOTE=ayushi agarwal;1224341] p.i = new getValue(); [/QUOTE] While I am sure your question must have been answered already, I am interested to know what does new getValue() do. | |
Re: Then to encrypt you use the formula C[i] = pow(M[i],e)mod n. Why are you using a for loop for this ? Similarly in the decrypt use the formula M[i] = pow(C[i],d). You dont need the for loop for that | |
Re: I have worked with Neteeza before . I think you will find the information that you are looking for in the manual | |
Re: Also dont run your loop till n. Run it till square root of n | |
Re: This is what I have understood so far.... When the value is 2 you are doing right circular shift and when the value is 3 you are doing left circular shift. You have some input How do you determine which values come into the result array ? | |
Hello Everybody, I have a small doubt regarding how we can call constructors in a C++ class [CODE]class test { public: test() { cout<<"In test\n"; } }; int main() { test t1; test t2(); // This call does not give compile time error but does not call the constructor cin.get(); … |
The End.