1,288 Posted Topics
Re: What input causes it to crash? Right now your crypto is very easy to break as it's not RSA. As I said in your other thread, **^** is *not* "to the power of". | |
Re: Seems like you don't understand pointers. Here is what I usually say about pointers to people learning about them. You are familiar with an int? An int is an object that takes up an amount of memory (commonly 4 bytes, sometimes 8) and stores a single numerical value. A pointer … | |
Re: Line 70. That function is meant to be called **main**, I expect. Those headers have proper C++ versions. **cstdlib** and **cmath** You'll need to specify that you are **using namespace std;** Rip out calls to **exit** and replace them with **return**. | |
Re: How would you do this on paper? Let's say that I give you two numbers (in decimal or hex, whichever you prefer to think about), and I ask you to write them down as ONE number, in such a way that you'd also be able to separate them out again … | |
Re: If you show us the code, we can tell you waht's missing. If I had to guess, you're missing a closing bracket, semi-colon or similar such syntax. | |
Re: The same way you'd do it on paper. | |
Re: // top level int stock1 = 0; // first way - pass by value and get return value stock1 = alterValueOne(stock1); // second way - pass a pointer to the variable alterValueTwo(&stock1); // functions int alterValueOne (int input) { int temp = input + 7; return temp; } void alterValueTwo … | |
Re: I see you're using the XOR operator here: m ^ e Did you mean to do that, or are you looking for the **pow** function? I see that at the end you output a single char only. Is that where you're expecting to see all the char output? | |
Re: You've got lots of problems in this code. The first thing I see that will break it is that you're trying to store the user input for their name as an integer. If they enter letters as their name, this will go horribly wrong and break all the following inputs. | |
Re: isdigit expects a single character. Just one. It's meant to be used to check if a single character is a digit (so the input is expect to have a numerical value in the range zero to 127 for a char, because those are the values a char takes - see … | |
Re: #include <string.h> (so the compiler knows about the function) sizeof (struct trainset) | |
Re: This is impossible. There is no way to know when you find the end of the array. It is up to you as the programmer to keep track of the size of the array when you make it. | |
Re: The only issue I can see is that sometimes you use the type client and sometimes you use Client. C++ is case-sensitive. It should be returned a pointer to Client. | |
Re: If your compiler is up to date, it will support regular expressions (#include <regex>), which means you can do something like this: regex userName("someString"); regex passWord("someOtherString"); while ( //loop over whole file, reading in two lines at a time and sticking them in stringFromFile) { if (regex_search(stringFromFile.begin(), stringFromFile.end(), userName)) { … | |
Re: If you just want to access pixel values, there are simpler ways. I like the CImg library. #include "CImg.h" #include <iostream> using namespace cimg_library; int main() { CImg<float> image("image.bmp"); CImgDisplay main_disp(image); // Display it, just for fun float pixvalR = image(10,10,0,0); // read red val at coord 10,10 float pixvalG … | |
Re: **What I have so far translates individual characters perfectly. But I can't seem to translate whole lines/words.** You read the input into the variable originalChar, which is a char. One char. Your function for decoding takes in one char, and the key, and returns one char. If you want to … | |
Re: [code]double & Getsomenumber() { double number = 12.4; double &anotherNumber = number; return anotherNumber;}[/code] As soon as this function ends, the variable number is removed and no longer exists. What does the returned reference actually refer to? Something that no longer exists. | |
Re: [QUOTE]Top reading that book! The compiler is old, non-c++ compliant, and the version of MFC that it teaches is also obsolete. If you want to learn MFC then get a book that teaches it from VC++ 2010 compiler. [/QUOTE] I respectfully disagree with that; I found the best MFC book … | |
Re: [QUOTE]C/C++ programmers are becoming dinosaurs for a reason...[/QUOTE] That is so true. I can't think of a single operating system, huge application or multi-million dollar game from the last year that was written in C and/or C++. | |
Re: You've not installed your compiler properly. Particularly, the path to the files it needs. | |
Re: #include "CImg.h" using namespace cimg_library; int main() { CImg<unsigned char> src("imageName"); int R = (int)src(c,r,0,0); int G = (int)src(c,r,0,1); int B = (int)src(c,r,0,2); return 0; } | |
Re: [B]i understand the 1/1000 chance then theres another 1/1000 chance of getting the song again next time, meaning 1/1000 X 1/1000 chance of getting the same song twice in a row using the shuffle.[/B] That's an analysis of not getting a SPECIFIC song twice in a row in two sequential … | |
Re: &(i) = new BrokenPart(i); This says: take the address of the object i (i.e. the number of the memory slot where i is) and change it so that it is equal to this other thing on the right (which is a pointer). That makes no sense. How can you change … | |
Re: Your chosen C++ development environment is so old that it doesn't have _getpid. Use something else. | |
Re: Since you created it, shouldn't you already know? [CODE]int x; // this one is an int float y; // this one is a float[/CODE] | |
Re: Get weight value from user. Get MET score for activity. Get time spent doing activity. Output (0.0175 * MET * time * weight/2.2) Which of those can you not do? | |
Re: [CODE]const uchar i0 = '30';[/CODE] '30' is not a single char, so there's the first problem. The single char: [B]char x = 30;[/B] is fine. In this case, the char is the RECORD SEPARATOR character, as show here: [url]http://www.asciitable.com/[/url] I don't know quite what you expected to add up to … | |
Re: [url]http://rosettacode.org/wiki/Caesar_cipher[/url] | |
Re: Try [B]std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');[/B] | |
Re: To change the contents of a file, the easiest way is to copy everything (but changing the bit you want changed, or just not copying the bit you want deleted) to a new file, delete the old one, and rename the copy. | |
Re: What exactly are you trying to do? [B]isdigit('1')[/B] will always have the same value. [B]isalpha('a')[/B] will always have the same value. Why bother using a function to generate values that never change and are always the same? What are you trying to do here? | |
Re: [url]www.norvig.com/21-days.html[/url] [url]samizdat.mines.edu/howto/HowToBeAProgrammer.pdf[/url] [url]www.catb.org/~esr/faqs/hacker-howto.html[/url] | |
Re: Sounds like you want to delete a value from the file "Tickets Left.txt". To do this, you'll have to make a new file, copy everything across that you want copied across, delete the old one and then name the new one with the same name. | |
Re: You are changing ptr BEFORE you copy the contents of the array, so when you copy ptr, you're copying garbage values. You're also causing memory leaks repeatedly; you [B]delete [/B]each array once, at the end, but you call [B]new [/B]many many times in your looping. | |
Re: [B]its returning false every time , thats the real trouble bcz apparently code looks fine [/B] This returns true. Perhaps you never gave it any decent test data. [CODE]#include <iostream> #include <cstring> using namespace std; bool substring(char A[],char B[]) { int aSize=strlen(A); int bSize=strlen(B); bool matched =true; int count =0; … | |
Re: Get first pointer. Count size of string. Get second pointer. Count size of string. Allocate new memory big enough for both strings. Copy contents of first string into new string. Copy contents of second string into new string. | |
Re: There are many ways to do this. Here are two ideas: In your code above, each time you draw a card, check to see if you've alredy drawn that one. If you have, reject it and draw another. Create all the cards in some suitable container - vector springs to … | |
Re: [CODE]#include <iostream> class test { public: int* num; }; int main() { test *d = new test; d->num = new int; *d->num = 3; std::cout << *d->num; }[/CODE] Edit: Beaten to the punch by seconds! | |
Re: Don't neglect maths. I am constantly interviewing coders who appear to have memorised all the syntax there is but can't explain to me how to manipulate vectors or normalise values (as just two examples). | |
Re: This is the exponentiation cypher, upon which RSA is based. Let's start with this. Pick a prime number, p. Pick another prime number e (smaller than p), making sure that e and (p-1) are relatively prime. Now, take your plaintext. Replace each letter by numerical equivalent (00 for A and … | |
Re: You're going about making the 2D array the wrong way. You have to separately create each 1D element of it: [CODE] Tests = new double*[numStudents]; for (int i = 0; i < numStudents; ++i) Tests[i] = new double[numTests];[/CODE] | |
Re: [CODE]while (notFinishedReading) { in_stream >> name; in_stream >> combo; in_stream >> op1; in_stream >> op2; in_stream >> op3; in_stream >> op4; // Do something with the data }[/CODE] | |
Re: [QUOTE]But what is the point of dynamic memory for a single type?[/QUOTE] What would you prefer? A minimum size permitted for dynamic memory? | |
Re: [CODE]getline(indata, temp[num].time);[/CODE] See that value, [B]temp[num].time[/B]? That's a [B]double[/B]. The getline function doesn't know what to do with it. It only knows what to do with strings. [B]temp[num].isEasy[/B] - that's a bool. The getline function doesn't know what to do with it. It only knows what to do with strings. … | |
Re: Does he mean "DOS", or does he just mean a command line window, in MS Windows? Anyway, clang is not VB. Use clang, as L7sqr suggested. | |
|
The End.