Forum: C++ Oct 2nd, 2009 |
| Replies: 4 Views: 296 I've always found it simpler to allocate a one-dimensional array, and then calculating the row and column manually, it's an easy approach, and it works. |
Forum: C++ Sep 25th, 2009 |
| Replies: 4 Views: 345 First thanks to add code tags to your post.
Second, (and I know this may sound harsh): your code is the ideal example of how one shouldn't program it, but no fear, we're here to help you and give... |
Forum: C++ Sep 25th, 2009 |
| Replies: 4 Views: 345 Ouch, my eyes!!
Please use BB Code and Inlinecode tags (http://www.daniweb.com/forums/announcement8-3.html)
What's the deal with void main()?... |
Forum: C++ Sep 21st, 2009 |
| Replies: 8 Views: 605 Since cake is a character array, the following instruction will allow an array overflow (in case there are more than 80 characters entered):
cin >> cake;,
you can prevent this by for example using... |
Forum: C++ Sep 19th, 2009 |
| Replies: 8 Views: 605 Post down your code please. |
Forum: C++ Sep 13th, 2009 |
| Replies: 36 Views: 1,455 This won't fix your problem, but it will fix a memory leak:
if you write this in your code: char *cool=new char[20];//the name pointer then at some point in future your program doesn't need the... |
Forum: C++ Sep 12th, 2009 |
| Replies: 36 Views: 1,455 Could you provide us with the file you tried to encrypt/decrypt using your program? |
Forum: C++ Sep 12th, 2009 |
| Replies: 36 Views: 1,455 Oh yes, and how do you explain the several minutes difference between all those posts then?
The post above this one (if not already removed by a moderator) is just the evidence that it hasn't... |
Forum: C++ Sep 12th, 2009 |
| Replies: 36 Views: 1,455 Okay, I really have enough of your double postings in your thread:
a) you won't get help faster by doing this
b) you just make your own thread unreadable
c) you waste your time, use that time to... |
Forum: C++ Sep 12th, 2009 |
| Replies: 9 Views: 1,048 if(currentChar<(char)'0' || currentChar>(char)'9'){
cout << "Invalid Pin" << endl;
}
Explicitly casting to a char isn't even needed here, the following code is equivalent:
if(currentChar<'0'... |
Forum: C++ Sep 12th, 2009 |
| Replies: 9 Views: 1,048 I guess you mean all characters other than 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 when you say: any non-numeric character.
Why not just get your number like this:
int num;
cout << "Enter a number: ";
... |
Forum: C++ Sep 9th, 2009 |
| Replies: 36 Views: 1,455 How I would go trough the process of designing such a program:
Create a simple menu, which will allow the user to choose whether he wants to encrypt or decrypt. (you've done this)
Create two... |
Forum: C++ Sep 8th, 2009 |
| Replies: 36 Views: 1,455 Is that the only reason you want to undertake all the work to write an encryption program?
Even if TrueCrypt is available for Linux as well ? |
Forum: C++ Sep 8th, 2009 |
| Replies: 36 Views: 1,455 As far as I know I only used cout, which you also did (you even mixed C with C++ I/O (which is also OOP), so I don't see where the problem is :)
Do you want to rewrite the whole program in C or... |
Forum: C++ Sep 8th, 2009 |
| Replies: 36 Views: 1,455 First of all I want you to NOT PM me with your questions to do it for you, it won't work, I'm a free person and I'm free to do what I want, and not to do what I don't want (let that be clear).
What... |
Forum: C++ Sep 6th, 2009 |
| Replies: 17 Views: 763 Well, you know the text editor? I meant: the program where you write your code in, launch that program, open the file containing the code of your program, copy that code, and paste it in a new post... |
Forum: C++ Sep 5th, 2009 |
| Replies: 17 Views: 763 To the OP:
No offense, but I can't trust the code you posted down.
Wait, let me explain, I came across a line which looked quite strange to me, and which will never let me compile this program:... |
Forum: C++ Sep 5th, 2009 |
| Replies: 17 Views: 763 Could you maybe explain us first what the goal of the program you posted is? (I mean: what output do you expect, etc.)
To answer the question in your signature:
Start a new thread about the bug... |
Forum: C++ Aug 31st, 2009 |
| Replies: 36 Views: 1,455 Your encryption algorithm should work fine, I tested it using the following code:
#include <iostream>
#include <climits>
int main()
{
int encrypt;
int decrypt;
for(int... |
Forum: C++ Aug 31st, 2009 |
| Replies: 36 Views: 1,455 I tested the program you posted, encrypting and decrypting is working fine, only one major remark I have is that the program hangs at the end of the encryption/decryption progress.
This:
... |
Forum: C++ Aug 30th, 2009 |
| Replies: 36 Views: 1,455 Can you show us the program with the changes you've made? |
Forum: C++ Aug 30th, 2009 |
| Replies: 35 Views: 1,683 I guess that it would be the best to just use Google to find yourself some examples, remember: Google is your friend!
I'm convinced there are plenty of examples on bitwise operators floating around... |
Forum: C++ Aug 29th, 2009 |
| Replies: 35 Views: 1,683 How do you mean: the bit cannot be toggled? By my means you can always toggle a bit: in case the bit is one, you toggle it, and it becomes a zero; in case the bit is zero, you toggle it, and it... |
Forum: C++ Aug 29th, 2009 |
| Replies: 35 Views: 1,683 Yep, if you use bitwise AND, then only if the two corresponding bits are one, then the bit in the outcome is also one, otherwise it is always zero (you can derive this rule from that truth table).
... |
Forum: C++ Aug 28th, 2009 |
| Replies: 35 Views: 1,683 >are they trying to turn off the last bit?
Did you maybe skip the truth table for AND-operations at the bottom of one of my previous posts?
Should I repost it again, or just give you a link... |
Forum: C++ Aug 27th, 2009 |
| Replies: 35 Views: 1,683 I don't quite get what you mean by this (even your example doesn't seem to help me understand what you mean).
Nope, most likely some decimal value will be displayed on your screen.
Could you... |
Forum: C++ Aug 27th, 2009 |
| Replies: 35 Views: 1,683 Yup! To understand how it works, you have to 'think binary' :)
Yes, as long as you choose a correct mask.
Well, say you want to turn off bit 3 of a certain value, then you first need to choose a... |
Forum: C++ Aug 27th, 2009 |
| Replies: 35 Views: 1,683 Let me explain this to you:
if ( b & 0x10 )
cout << "Bit four is set" << endl;
else
cout << "Bit four is clear" << endl;
To start off: 0x10 is the hexadecimal number for 16 (in... |
Forum: C++ Aug 26th, 2009 |
| Replies: 35 Views: 1,683 Not always necessary, but in this case it seems most appropriate.
Just take the way which is easiest for you, and in most cases, it's directly inputting the value.
(If the value is in another base... |
Forum: C++ Aug 25th, 2009 |
| Replies: 35 Views: 1,683 Quick fix for anyone who's reading this thread: when you read one of my previous posts, replace every 16 you encounter with a 15 :) |
Forum: C++ Aug 25th, 2009 |
| Replies: 35 Views: 1,683 I guess you misunderstood my previous post, wait let me explain it again:
As you know, C++ is a programming language, to make it a bit more complicated: C++ offers support for variables.
When you... |
Forum: C++ Aug 24th, 2009 |
| Replies: 35 Views: 1,683 Nope, a value in an integer variable is technically stored as a binary value.
For example: whether you assign 16 (in decimal), or 0xF (in hexadecimal) to an integer variable, the integer variable... |
Forum: C++ Aug 23rd, 2009 |
| Replies: 35 Views: 1,683 0xF7 is a hexadecimal number, it is the same as 247 in decimal.
But in C/C++ you don't have to convert it or something, you just set your mask to 0xF7.
You'll probably say: How do I do that?... |
Forum: C++ Aug 22nd, 2009 |
| Replies: 35 Views: 1,683 Short answer: take a value where all bits (except the third) are 1 (the third needs to be 0), this is your mask.
Then you (bitwise) AND it together with the value where you want to set the third bit... |
Forum: C++ Aug 22nd, 2009 |
| Replies: 5 Views: 374 Having a hard time using Google?
My first advice before starting a new thread is: STFW first!
... |
Forum: C++ Aug 22nd, 2009 |
| Replies: 4 Views: 442 Well, hard-coding the whole alphabet in your program is possible, but there's another way, without needing to hard-code the whole alphabet in your program, let me describe it:
The above sample run... |
Forum: C++ Aug 22nd, 2009 |
| Replies: 4 Views: 442 I'm sure you can, when you do some effort:
http://www.daniweb.com/forums/announcement8-2.html
Sure, don't take this wrong but I would like to see first that you've at least tried to solve it. |
Forum: C++ Jul 30th, 2009 |
| Replies: 9 Views: 248 Remove this line from your code (if you don't make use of the Allegro library):
#include <allegro.h>
Or if you're using Allegro:
If I'm not wrong each Allegro program looks like:
#include... |
Forum: C++ Jul 30th, 2009 |
| Replies: 3 Views: 200 Well, try this one:
wordRecord test; // (1)
sc.printDict(test);
(1): You can put struct at the beginning of this line, but this isn't obligated in C++. |
Forum: C++ Jul 30th, 2009 |
| Replies: 13 Views: 623 An addition for the OP:
Also ensure that the variable newSize is of type size_t.
Strings don't have negative lengths, so using int isn't the best option here (because it's signed, this means that... |