In any case, we are starting to reach certain physical limits that prevent much further improvements
I seem to recall those same comments about computers in the 1980s.
In any case, we are starting to reach certain physical limits that prevent much further improvements
I seem to recall those same comments about computers in the 1980s.
Did you buy it yourself or get it as a gift? When you have to pay for it yourself then you'll be a little more careful.
Has to be vinalla ice cream, never tasted a bad brand of it. Baskin- Robins is good, but, like Starbucks, is overpriced.
Never read the books, but the movies are pretty good.
Assembly Guy told you how to solve it -- nobody is going to write the program for you. I'm sure if you just used google you could find lots of programs.
std::copy() does quite a bit of work before calling memmove(), so why not just call memmove() directly?
Also sure copy uses memmove() because C++ is build on C
That is only partially true -- C++ standards don't tell compiler writers how to implement c++ functions, just how the functions are supposed to work. std::copy() could have been implemented any number of different ways, such as using software loops. But on Intel-based systems memmove() is the most efficient way to do it because of the underlying assembly code instructions.
Yes, it doesn't have to return anything, but string functions often do so that the function can be nested inside other fuctions, for example
printf("%s\n", rtrim(somestring, ' '));
I grew up, I didn't raised up.
Every major pole shows Obama's disapproval rating at or near 53+% which is among the worst in US history. I suspect a lot of that is due to the Obamacare web site fiasco and the misinformation about keeping one's healh care insureance.
I bought a Galaxy Note 3, nice large screen yet small enough to put in my pocket. And it doesn't say Apple on it :)
And all this time I thought beef was bred, not grown
How do you think baby cows get to be adults? Just like human children -- they are grown.
Beef is not grown in Canada?
Didn't know that, I thought the winters were too severe for them, but I've never been in Canada.
I hear MACs are good at that :) A friend of mine has one and it's always crashing.
My compiler, vc++ 2012, produces errors when I compile your function that uses std::copy(). I changed it like this to remove the error
vector<int> exp(int *arr, int size){
vector<int> temp(size*2);
std::copy(arr, arr+size,temp.begin());
return temp;
}
I used debugger to single-step through the code of std::copy(), and just as I suspected it eventually uses the standard C function memmove() to do the actual copy. Of course other compilers may implement std::copy() differently.
Which is identical to what I posted 21 hours ago :) Now you're just repeating what's already been said.
Alaska would be more similar to Canada then continental US because ground beef would probably be too expensive since it has to be shipped in. AFAIK beef is not grown in Alaska or Canada.
His second term is starting out as a big disaster. Nothing at all like he said it would be when campaigning for his first term.
shut down in the us.
Probably world-wide event. Knock out the sattalites and all communications and computers as we know it today will stop.
Does that mean you are trying to write your own compiler? If yes, then check out Yacc (Yet Another Compiler Compiler) or Bison which translates Yacc code into C code.
can anyone tell me all the macro consts?
Huh? See this article. macros are evil -- sould not be used.
One way to accomplish what you want might be a little complicated. Make an array of Account objects and add a member to Account class that is a string in which you can store the instrance's name. Then if you say you want to work with account 222 you would search the array for the name that is "222".
But as others have said once you compile the program the name of the object is written in stone and cannot be changed.
line 17: That does not copy all the elements of one array into the other array, it is mearly an assignment operator that set the address of temp to be the same as arr and the memory allocated at line 16 is lost.
this produces an error
int *exp(int *arr, int size){
int *temp=new int(size*2);
temp = arr;
for(int i = size; i < size*2; i++)
temp[i] = i*2; // <<<<<< Runtime error here
return temp;
}
Don't worry i don't know what your talking about
Then don't post in the thread.
did you forget to include iostream?
#include <iostream>
using std::cin;
using std::cout;
// the rest of your program goes here
you cannot sell a "beef taco" if you cannot show that it actually contains beef
So what do they use up there in Canada?? The Tocco Bells around here use hamburger, which is ground beef. At least I don't think they use horsemeat or dogmeat.
I'm not a big fan of Tocco Bell, but I get some toccos maybe once every three or four months. I am a Big Mac fan.
you can also do it without a loop by calling memcmp(), which compares two arrays byte-by-byte.
int a[] = {1,2,3,4,5};
int b[] = {1,2,3,4,5};
if( memcmp(a,b,sizeof(a)) == 0)
{
printf("They are the same\n");
}
else
{
printf("They are different\n");
}
The easiest way is to rearrange main() just a little by putting almost everything in another loop. Notice that the file is only opened once at the beginning of main() so that each scanf() will read the next word in the file. You need to add a check for EOF.
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define S 25
main()
{
//declare variables
FILE *fp;
fp = fopen ("words.txt", "r");
for(;;)
{
int i;
int x;
char wtbg[S] = {'\0'};
char gl[S] = {'\0'};
char wip[S] = {'\0'};
char guess = ' ';
int numguess = 0;
int numLetters = 0;
int theSame = 0;
int wresult = 0;
//displays instructions for user
Instructions();
//get word from file
fscanf(fp,"%s", wtbg);
//copy length of wtbg to wip array
numLetters = strlen(wtbg);
DisplayArray(wtbg);
//printf("GUESS=%d", guess);
//fill wip
for (i = 0;i < numLetters; i++)
{
wip[i] = '*';
//printf("%c", wip[i]);
}
wip[i] = '\0';
while (numguess != 6)
{
printf("GUESS THIS WORD:\n");
DisplayArray(wip);
guess = tolower(GuessLetter());
gl[numguess] = (guess);
printf("\nLetters guessed so far: ");
DisplayArray(gl);
wresult = CompareLetter(wtbg, guess, numLetters);
printf("wresult=%d", wresult);
updateWIP(wip, guess, wresult);
//theSame = CompareArray(wtbg, wip, numLetters);
//printf("\nAre they the same array? %d", theSame);
//printf("NUM LETTERS = %d", numLetters);
//update number of guesses
//wresult = 0;
numguess++;
// ask if you want to guess another word goes here.
}
//printf("GUESS=%d", guess);}
}
return 0;
}
Did you follow the steps to compile CEGUI library as explained here? It looks like all you get is the source code and you have to compile it yourself to generate the DLL.
line 50: This is always reading the first word that's in the text file. You need to read a random word. After you've guessed the word correctly it's not much fun to use the same word every time you run the program.
Actually, now that I think about it you don't need to use a text file at all. Just get a word of random length and fill it with random letters. The word will be meaningless, but will always produce a random set of letters to choose.
lines 62-67: Initialzing wip is being done on every loop iteration, you don't want to do that. Move the while statement on lines 57 and 58 down to below line 67 so that wip is only initialized once before asking for user input.
line 84: You need to stop the loop when the user has entered the correct word, if the word is "one" then you don't want to keep on asking for letters after you've guessed the word. A simple check with strcmp() will solve that little problem.
Here's an interesting article about how computer speed has changed since the 1980s. That's not to say that processor speed will continue to increase at that rate, most likely motherboards will just support more cores, for example the processor in my computer has 8 cores, and I know of motherboards that can handle 2 processors which would give it 16 cores. That's an awful lot just for me to play a few games :)
strncpy() is similar to strcpy(), both functions take two null-terminated character arrays as arguments. So neither of those functions will work in your situation.
Before calling updateWIP() array needs to contain the same number of characters as in the word that the user is trying to guess. So if the word is "hello" then array needs to be initialized with 5 spaces. If that is done your updateWIP() should work, assuming the value of result is one of the numbers 0, 1, 2, 3, and 4.
Did you write a prototype for Complement() before main() or does the function appear in the source file before main() ? For example:
void compliment(int a[], int m); // Function prototype
int main()
{
}
void compliment(int a[], int m)
{
}
The loop on line 36 is wrong
int *expandArray(int arr [], int size)
{
int *newArray = new int [size * 2];
int index;
for (index = 0; index < size; ++index)
newArray[index] = arr[index];
// for (int newElem = 10; newElem <(size*2); ++ newElem)
while(index < (size*2))
newArray[index++] = 0;
return newArray;
} // end *expandArray
You can also get the same result by not using the loops at all.
int *expandArray(int arr [], int size)
{
int *newArray = new int [size * 2];
memset(newArray,0,size*2*sizeof(int));
memcpy(newArray,arr,size*sizeof(int));
return newArray;
} // end *expandArray
That's right -- drawing must be done in the same thread as the window or dialog box.
I don't get any errors with that code using VC++ 2012. The error is probably somewhere else.
Les Visiteurs -- the funniest movie I have ever had to read (subtitles)
could this be a defect of _beginthread?
No -- that's how Microsoft designed the api.
Not that I know of.
I don't think you will ever find a "complete" word list -- new words are added to the Engligh language all the time. Have you searched for "dictionary database" ? If all you can find are files that contain definitions, then write a short program to strip off the definitions and put the words into a new file. If you are on *nix then you might be able to do that with sed program.
You can't -- drawing must be done in the same thread as the dialog box. If you don't want the dialog box in the same thread as the parent then either put the entire dialog box in another thread or create a modeless dialog box.
Why Windows Threads Are Better Than POSIX Threads (e.g. CreateThread() better than _beginthread() )
I think it's just the normal Command Prompt window.
The function is for right-trim, so the value of string will not change. All the function does is start at the end of string and work backwards until it finds the first non-junk character, then truncates string at that point.
I'm not saying it's impossible, but normally the parent will send a message to dialog so that dialog can update the text in the dialog's window. You can set up private messages to do that.
Just to clarify, you mean that if you up voted a post with comment it would be considered as a reputation point but if I up vote a post with a comment it would not affect the reputation points?
Look in the member's profile and it will tell you the number of rep points that the member can affect when upvoting with comment (assuming he/she currently has positive rep). For example if I upvote your post (other than in Community Center) it will increase your rep points by 14 points. If Deception upvoted your post he will affect your rep by 13 points, and Deep Modi will affect your rep by 1 point. So if all three of us upvoted your post then your rep would go up by 28 points, not 3 points.
Did you compile for debug then use it's debugger to single-step thorugh the program? How many elements are in the data array? Does the value of (j+i) exceed the number of elements in the array?
What compiler and operating system are you using? Have you checked the size of the arrays that the program is using to see if it's attempting to write outside the bounds of the array?
after getting 5 posts voted up without a comment can be equivalent to one post voted up with a comment
Won't work because different members affect reputation in different ways when leaving a comment. The number of rep points that I affect are a lot greater then the number of rep points that you affect, so if 5 people upvote someone how would DaniWeb program know how much to increase rep points?
Functions are coded as normal.
class MyClass
{
public:
static int x;
static int foo();
};
int MyClass::x = 0; // static variables must also be declared like globals
int MyClass::fo()
{
return x;
}
int main()
{
MyClass::x = 1;
}
parent window shouldn't be trying to draw on the dialog box -- let the dialog box do all the drawing.
Pulled pork sandwitch -- Yummy!