519 Posted Topics
Re: Your first post says that you have to use functions ... Do you know what functions are ? Post #5 contains the skeleton of a function in C++. This link gives you another example [url]http://www.cplusplus.com/doc/tutorial/functions/[/url] Now you want to move the part of code between line 22-24 in the function … | |
Re: Dude you got to post some more code ..... What is the structure definition ? How exactly are you passing it ? How are you printing it ? (The complete statement ) Since I have absolutely no clue as to what exactly is your problem, here is a shot in … | |
Re: On line 51 why are you closing the server socket ? Should that not be like the last step of the program ? | |
Re: You dont need hep ... You need the program .... | |
Re: I thick you can use fseek. But you have to know how many position you want to go from start/ end of file [url]http://www.cplusplus.com/reference/clibrary/cstdio/fseek/[/url] | |
Re: You have 2 return statements on line 46, 47. The one on line 47 will never get executed Similarly you have a return statement on line 52. So the code from line 53 onwards cannot execute | |
Re: B tress are pretty common. You might want to check out suffix trees as well. | |
Re: Look closely into you for loop. This is the statement that you have written [CODE] total += a[MAXVALS]; [/CODE] What this means is that you are adding the value stored in a[100] num times. Is this what you want to do ? | |
Re: Quick question, what is the relevance of the pink rows and blue rows ? Also I am not sure I follow the explanation of the problem. Does it happen that when you display the grid the location of the mines are visible or are they hidden like the game minesweeper … | |
Re: If you the format of the data then you can use the fscanf function If not use read to read the contents of the file into a char array and then implement a parser to parse the data | |
Re: Maybe this is a stupid question but what will be the value of size when the entire page is read ? Wont it be 0. Cant you use that check to determine when the page is read ? Or am I missing some thing ? | |
Re: Quick question.... Are you storing the information about the books in a data structure or in a file ? The reason I ask is that you have a ofstream object in your delete file function | |
Re: There are 2 -3 compile time errors in your code.. [QUOTE=e30rapidic;1204376] [CODE] #include<iostream> #include<vector> #include<iomanip> #include<string> using namespace std; class Person { private: string name; // Make this bestFriendName. You have used bestFriendName in the function definitions Person* bestFriend; int count; public: void setName(string n) { name = n; } … | |
Re: Line 14 of your code is [CODE] (strings, n, sizeof(char *), compareStrings); [/CODE] What is the purpose of this line ? From what I have understood of your code I think you are taking the input correctly. One way to out put the words randomly would be to use the … | |
Re: [QUOTE=Priyanka88;1205040]hello, i am student and i want to know more abour binary expression tree...i hav idea about creating binary search tree ....bt v r suposed to create binary expression tree....e.g..for a+b....+ (infix/prefix/postfix) / \ a b will u plz help me how to proceed??[/QUOTE] Check out this link .... Maybe … | |
Re: Dude the variable size is initialized to 0. You dont change its value any where in the program. Give it the value of string length at some point of the program | |
Re: I dont think [code=c] printf("%5s", "*"); [/code] can be put in a loop..... | |
Re: Probably some thing of this sort [CODE=C] void rev(int* arr, int lower, int upper) { if ( lower >= upper) return; // Swap the 2 values rev(arr, lower+1, upper-1); } [/CODE] Where lower and upper are the smallest and the largest indexes of the array | |
Re: Dude Where are your code tags I am reading your getCalendar date function to print the date in the proper manner, but just a quick question, cant you read the file line by line and into a char array and then use strtok with space as the separator ? From … | |
Re: Use code tags..... It makes it much easier for us to understand your code when you use code tags When I compiled your code, I get an error on this line if(Ranks[Deck[CardDrawCount] % 13] == 0 ) The reason for this is that this expression becomes (when CardDrawCount is equal … | |
Re: @Banfa ... When you calculate new number of trucks and load per truck why will you get a different value ? | |
Re: Check out this link .... Maybe of help [url]http://www.dreamincode.net/forums/topic/37428-converting-and-evaluating-infix-postfix-and-prefix-expressions-in-c/[/url] | |
Re: I dont think the logic used by you is correct . Check out the method shown in this link...... Its far more simpler as compared to your code [url]http://www.knowledgesutra.com/index.php/Data-Structures-Linked-List-Reverse_t52777.html[/url] | |
Re: Also for your program it would make sense to change the data type of choice to int as opposed to what you have now | |
Re: If you are looking for a direction to get started at least .... Try making a text editor first which has the basic functionality like Notepad .... Once this is done (and you are still determined to move ahead) then you can think of more advance functionality | |
Re: Also line 75- 79 check where you have put the ' { ' Is that the correct place ? | |
Re: Maybe this link will be of help ? [url]http://www.google.com/search?hl=en&q=birthday+paradox+c%2B%2B&sourceid=navclient-ff&rlz=1B3GGGL_enIN258IN259&ie=UTF-8&aq=1&oq=birthday+paradox+c[/url] | |
Re: I have written a simple example which shows how you can use the void pointer to pass an integer value. Maybe this will be of help [CODE] void func(void* p) { int *x= (int* )p; printf("%d\n",*x); } int main(int argc, char* argv[]) { int x=10; void* p= &x; func(p); cin.get(); … | |
Re: [CODE] struct Foo { char* value; }; // are a and b created in the data segment of the asm. The data is probably is the code segment struct Foo a = {"Hello from variable a"}; struct Foo b = {"Hello from variable b"}; int main() { // what will … | |
Re: The method used by you to check if the num exists in that particular row or column is correct (though inefficient ) Checking if the number exists in that box is a bit tricky ..... You want some thing of this sort [CODE] // All the boxes are 3 * … | |
Re: 1. In the code that you have posted, you have defined the function read in the function main ..... Put the brackets properly 2. Check how you have called the read function. Is that the correct way to call a function 3. I would recommend changing the name of the … | |
Re: The logic that I would use for this problem will be as follows : Input Array A[50]: Temp Array B[50] for(i=0;i<50;i++) B[i]= A[i] - target Sweep thru B and find the greatest -ve number and the smallest positive number . Let the indexes of these values be i1 and i2 … | |
Re: Could you post the part of the code where you read from the file and then call the function | |
Re: You are passing both the array by value (syntax for this is also wrong). Change this to pass by pointer There are more serious bugs ... Will try to get back to you in some time on those | |
Re: Google for srand You want some thing of this sort ... After you have got random numbers in i and j [CODE] if(i==j) { // Do nothing } else { // Execute the loop below } for(z=0;z<20;i++) { if( (map1[z]==i)&&(map2[z]==j)) { //Do nothing } else { // Insert into the … | |
Re: Check out this link ... [url]http://www.cplusplus.com/forum/beginner/7386/[/url] I think this should solve your problem .... | |
![]() | Re: You can use the fscanf method. [CODE] int buf1[100]; fp1=fopen("data.in","r"); // Open the file containing data in the input mode if(fp1==NULL) { printf("%s","Could not open source data file"); // If the file cannot be opened the program exits exit(1); } else { while(!feof(fp1)) fscanf(fp1,"%d",&buf1[i++]); // Read the data into the … |
Re: There are many more mistakes in your code... 1. When you are accessing the matrix elements the for loops should be [CODE] for(i=0;i<3;i++) { for(j=0;j<3;j++) { // Do printing checking what ever } } [/CODE] 2. Initialize count to -1 3. When you are checking for repetition, you have to … | |
Re: Check out this link [url]http://www.prasannatech.net/2008/07/socket-programming-tutorial.html[/url] In the example code of TCP Client, there is a line host = gethostbyname("127.0.0.1"); In place of 127.0.0.1 you can use the name of your server | |
![]() | Re: [QUOTE=tcstom;1197081]I tried changing the code to: [code] void AddDevice(int Foo, unsigned int Bar); unsigned long* ptr2data; DWORD temp; *ptr2data = (unsigned long) SomeArrayOfData[4]; temp = (DWORD) ptr2data; AddDevice(7, temp); [/code] as suggested by Jephthah, and it didn't work :( The method suggested by Deeep wasn't very clear, I tried changing … ![]() |
Re: [QUOTE=mystb;1196799]I think we finally have something. Because for small letters (like a b c) it works but for others (like u r k) it just gives -1943. I think this is because of data type. (which is int). u is 21 and 21^13 is really big number so i thought … | |
Re: [CODE] char *letter; if(info[i].grade >= (mean + 1.5*stddvt)){ info[i].letter= "AA"; [/CODE] This code is wrong. When you say char* letter you just have a pointer. For storing data the pointer has to point to some memory. Check out the function malloc | |
Re: I guess the terminating condition could be when all the fruits are un reachable( height wise) .... | |
Re: Use this to read a file line by line [code=c++] char buf[20]; while(accountsinFile.getline(buf,20)) { cout<<buf<<endl; } [/code] After this you can parse the string in buf and store its contents in the data members of the struct | |
Re: Also what are these functions qinit, qremove, qadd ?? Are you sure there are no errors in these functions ? | |
Re: [QUOTE=smeghead007;1161289]so should i put the file into an array ie num_array[500] and read the file into the array so i can access num[1] num[5] etc.. and sort them would getline put them in an array though[/QUOTE] Yes . But one point of caution. Make sure the size of the file … | |
Re: Write the ndice function this way [code=c] int Ndice ( void ) { int nrolls = 0; while( /*loop infinitely */) { printf ("Please enter the numerical amount of dice you would like to roll (maximum 10):\n"); if(/*If the value entered is not correct */ { // Print the error … | |
Re: [QUOTE=Xufyan;1167124]Hey Thanks...and how to calculate remainder of [icode]a[/icode] and [icode]b[/icode] only if [icode]b[/icode] is one less than [icode]a[/icode] ?? i mean when the values of [icode]a[/icode] and [icode]b[/icode] are same then the remainder must not be calculated ?[/QUOTE] Put an if condition [code=c] if(/*check if b is less than a … | |
Re: Get started with you HW Post your progress and a specific question If you just post the question that you got for an assignment without showing your efforts then you will be ignored | |
Re: [QUOTE=xavier666;1161918]I don't get this error. I mean if i try to free a NULL memory, it does not say anything. Hey! Look at line# 2 :P This was another one of my doubts. If i don't type caste calloc/malloc, my compiler is giving me errors. Take a look [CODE]# include … |
The End.