- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 8
- Posts with Upvotes
- 8
- Upvoting Members
- 7
- Downvotes Received
- 10
- Posts with Downvotes
- 7
- Downvoting Members
- 5
I'm no nerd. I'm a hunk :)
- Interests
- Lifestyle & Sports... and of course everything techie
138 Posted Topics
Re: No one would ever want to implement a database using text file. The work involve are just very tedious. First of all, what are the 'data' that will be stored in your database? If it is all of a user defined structure, you can consider storing them as a binary … | |
Re: It seems that I can run the .js file from Windows. Just double click it. | |
Re: Here are some codes which you may use to record the time. [CODE] #include <time.h> time_t start, end; double duration = 0; time(&start); // your codes here time(&end); duration = difftime(end, start); // time in milliseconds [/CODE] | |
Re: If you wanna stick to your code, its fine. Just make some modification for an elegant solution. Here's my advice. I prefer to seed the random number generator first, then use the modulus (%) function to limit the generated number. [CODE] #include<iostream.h> #include<stdlib.h> #include<time.h> int main() { int i; cout<<"ten … | |
Re: Is that all the codes that you have? Did you ever set any value to your variable 'commonVar1' before calling GetcommonVar1() method? If not, I suppose the result would be unexpected and the -1 is only a coincidence. If I'm not wrong, the child's property 'commonVar1' takes precedence over the … | |
Re: I don't see anything wrong with the OOP concept being used. And in fact, it is recommended practice so that they can be reused in future. Also, I do not see any error with the code. What's the number that caused the problem? | |
Re: Your function to delete the last element from the linked list is good enough. However, do take note of the issue raised by arkoenig regarding the code [CODE] delete last; [/CODE] which apparently doesn't appear to be meaningful in the codes given. Do take note about the existence of other … | |
Re: You are getting the codes wrong. Particularly at line 14 [CODE] int fgetc(FILE *stream); [/CODE] This line is not needed. Line 18 until line 34 (while loop) can be rewritten like below [CODE] c = fgetc(stream); while(c != EOF) { // logic goes here c = fgetc(stream); } [/CODE] | |
Re: [QUOTE=chikkupa;1431171]Edit your code as: [CODE]case 2: cout<<"Enter the Customers National Number ID"<<endl; cin>>ni; for (int i=0; i<150;i++) { if (ni==CustArray[i].customer_id) { CustArray[i].showCustomers(ni); } } break;[/CODE] [CODE]// Here loop is removed void Customers::showCustomers(int ni) { if (ni==customer_id) { cout <<"Customer Information"<<endl; cout <<"*********************"<<endl; cout<<"Customer ID:"<< customer_id <<endl; cout<<"ID:"<< id <<endl; cout<<"Name:"<< … | |
Re: I don't think you can read int from the file using ifstream. The problem with your code is that they are displaying the memory location of your array. Is there any reason to use an int array? You can use the read or readline function of the ifstream to capture … | |
Re: [QUOTE=jeffpro;1431218]no those are the hex values that should be placed in the byte accordingly. char Hi[4] = "3E2C"; needs to be converted into: Bye[0] = 0x3E; Bye[1] = 0x2C;[/QUOTE] Firstly, you got to read the Hi array 2 characters at a time. For the first character, bit shift it to … | |
Re: You can include an object of class Date into Flights just like any other data types. Your initialization of the Flight classes are correct. | |
Re: Your sum function is only taking the last value entered by the user as stated below: [CODE] sum=a[x]; [/CODE] The code comes after the for loop. At this point, the value of 'X' would have been 10 and its surprising that you are actually able to execute your program without … | |
Re: Debug mode lets you step in to the code and observe whats happening behind the scene as your code runs. You can put breakpoint to stop the execution of codes at the certain statement. In addition, you can also investigate the value of a variable when running in debug mode. … | |
Re: If you're interested and serous about picking the language, get a good book. [The C++ Programming Language: Special Edition] By the creator of the language | |
Re: Please describe your problem. What's the problem you're facing. Only then, people will know how to help | |
Re: It seems like your fifth line is of different format from the rest. Its really difficult to work with file of this kind as its data can take many forms. This is a general rule: For you to read data from file, you'll need to know the format beforehand. The … | |
Re: I don't see why your code doesn't run. Your GetNext() method should be called three times as stated by VernonDozier. Hence, the same piece of information is printed on screen three times. The only reason for the program no running properly (that I can think of) is the license.txt file … | |
Re: You could code it this way to request user to enter password [CODE] cout << "Enter password for user: " << username << endl; cin >> password; [/CODE] | |
Re: The .H (header) file is more of a code organisation means to make your code readable and easily maintained. Logically, declarations and definitions are placed in the header file to allow an easy glance over the codes. All implementation codes shall go to the CPP file (with same corresponding name) | |
Re: The function's name buildBackward doesn't describe what's been done in the function. Basically, the function builds a list with all the numbers entered by user. After the number -999 is encountered, it returns a pointer to the first node of the list. Having this pointer, the printList function iterates until … | |
Re: 1000 bits = 125 bytes Therefore, to read 1000 bits, all you have to do is reading 125 bytes. Using the example given by Ancient Dragon, your code should looks like: [CODE] unsigned char buffer[125]; ifstream in("filename", ios::binary); // provide extension to filename if exist in.read(buffer, sizeof(buffer)); [/CODE] Be very … | |
Re: First off, what class do you want to inherit? Since there is no mention of a third class, it's hard to guess what class you want to introduce. Inheritance is easy. Let's say I am introducing a ChildSavings class which will inherit from the Saving class, the code would just … | |
Re: The ASCII table shows that A - Z has ASCII code of 65 - 90. On the other hand a - z has ASCII code of 97 - 122 You could manipulate the text as 'char' using ASCII code. For example, in the Caesar cipher, B (66) would be E … | |
Re: Let's post some of your initial work and we shall assist you on any problem which you may have. Or at least, post some of your thought on how you're gonna solve the problem. | |
Re: You may use if..else statement inside a case of a switch. For example, [CODE] int i = 2; bool a = true; switch(i) { case 1: cout << "Case is 1"; break; case 2: if(a) cout << "Case 2 and boolean a is true"; else cout << "Case 2 and … | |
Re: Lanor, NULL is a non-display value meaning that it cannot be seen even when it's be written to the file. In the case where you want to display the word 'NULL', you should check for null value in the grade array and explicitly display 'NULL'. Here's an example [CODE] infle … | |
Re: This is C++ and it is different from C#. You use the symbol '<<' to redirect your stream to the intended output. For example, to output the regular hours is simply: [CODE]cout << "Regular Hours Worked: " << regularHours << endl; // you would want an end of line here … | |
Re: Error LNK2019 relates to the failure of the compiler to locate an external symbol referenced in a function (linker error). Is your rstream header file in the same folder as your CPP file? Whats the full error message? Mind to post it here? | |
Re: For me, inline function is used in the situation where it will only be called from one place. The main purpose for me to implement it as an inline function is solely readability and design. That's when my function is getting too long and there are too many nested conditional … | |
Re: This has got to do with your header location in the physical directory. Check that it is in the same directory as your CPP file. Otherwise, you may specify the relative path of the file in your include statement. | |
Re: Emphasis should also be given to naming convention used for variable, method and class names. They should be short, precise and descriptive. It is one of the area that is not given its due diligence. Imagine yourself read a function name and wondering what the heck does this function do! … | |
Re: Please note that your declared pointer is only a character pointer. [CODE]char* pointer;[/CODE] You should delete in this way [CODE]delete pointer;[/CODE] No need for the square bracket as it is not an array pointer. | |
Re: Why not you try to GetChanges() on the modified version of your datatable? Since you mentioned that it is a modified of the original, I guess you should be able to get the changes from 'dtModified' [CODE]dtModified.GetChanges();[/CODE] | |
Re: Please the "using" directive after all include files. Like this: [CODE]# #include "Customer.h" using namespace std; [/CODE] | |
Re: Instead of escape characters, you can use the '@' symbol before the string. E.g. @"This is "an" example of 'escape' characters" | |
Re: Are you missing the include header directive in both of your CPP files? It looks something like this: [CODE]#include "GradeBook.h"[/CODE] | |
Re: It seems to me that your copy logic is not right. [CODE]//copy linked list while(curr != NULL) { node* copy = new node; copy->info = curr->info; copy->next = NULL; curr = curr->next; } cout << "The list was copied."; [/CODE] Observations: 1. You do not have a pointer to point … | |
Re: Based on the code posted, I assume that it is running on the main thread. Calling Sleep() from the main thread causes the program to pause for the specific amount of time. All others background threads will still be running and doing some work. If you need some background work … | |
Re: [CODE]while (!cin.eof()) { cin >> value; list.insert(value); }[/CODE] It seems like the program will store whats in the variable 'value' when Ctrl+D is encountered. Apparently, at the point of Ctrl+D, the final valid value stored in the variable 'value' is 5 which is then inserted into the 'list'. That is … | |
Re: Human tend to be creative and bend the rules. There is no way to be sure that the input you received is in integer format. The best way is to read line and then try to parse the string into integer. E.g. [CODE] #include <stdlib.h> int i; char num[256]; cin.getline(num,256); … | |
Re: Care to explain what is the first post (the image) about? Is it some kind of assembly function capability? | |
Re: There are several mistakes in your code. I have corrected them and look out for the comments in the codes below: [CODE] #include <stdio.h> #include <stdlib.h> #include <ctype.h> #define MAX 100 int main(int argc, char *argv[]) { int i, j = 0, sum = 0; int a[MAX]; // i start … | |
Re: By implementing a binary search tree, it is presumed that the key value is sorted. In your case, the 'id' is sorted. One thing to note about your implementation is that, the stopping condition have to be check first. If the 'id' is not found, then check if it is … | |
Re: Here's an example of working linked list. Basic functions such as add to list, clear list and print list elements are provided. Hope this helps you to understand better. [CODE] #include <iostream> using namespace std; struct input { int id; // current id input *next; // pointer to next input … | |
Re: Do note that this will only write one Matrix into the file. [CODE]stream.write((const char*) &myMatrix, sizeof(Matrix));[/CODE] Just replace the pointer of myMatrix to the location of your matrix array and the size to the total number of matrix multiply by sizeof(Matrix) | |
Re: There are other errors as well. Your firsttry variable are calling the methods wrongly. [CODE] int main() { MyBST firsttry; firsttry.add("name"); firsttry.display(); while(true){} return 0; }[/CODE] The add function needs 2 parameters and there is no display function defined for MyBST class. Here's a working piece of code: [CODE]// TreeNode.cpp … | |
Re: Let's see what you've got worked out so far. Show your code here and many will be willing to help. | |
Re: Your logic for comparing palindrome is wrong. Palindrome ignores the placement of spaces. It only cares about the reversal arrangement of letters. You could use the reverse string function as below: [CODE]char* ReverseString(char* oriStr) { int cnt = 0, i = 0; int len = strlen(oriStr); char *revStr = new … | |
Re: Explaining the differences between C and C++ in this thread is simply insufficient. It is better for you do look up other resources on the Internet. [URL="http://www.cprogramming.com/tutorial/c-vs-c++.html"]http://www.cprogramming.com/tutorial/c-vs-c++.html[/URL] [URL="http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B"]http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B[/URL] [URL="http://zarrata.com/durofy/computers/programming/10-major-differences-between-c-and-c/"]http://zarrata.com/durofy/computers/programming/10-major-differences-between-c-and-c/[/URL] C++ is the superset of C. One of the major difference is that C++ supports object-oriented programming while C does not. … |
The End.