>>line 20: b=(i+1)/10;
This is odd coming from a professor. All values of i that are less than 10 will result in a value of 0. Values of i between 10 and 19 are 1, etc. Why would you want to initialize an array with those kinds of numbers?
>>line 20: b=(i+1)/10;
This is odd coming from a professor. All values of i that are less than 10 will result in a value of 0. Values of i between 10 and 19 are 1, etc. Why would you want to initialize an array with those kinds of numbers?
and if A is initially even, don't do anything.
Post some sample code that calls that function. Lines 30 and 31 could very well be reading beyond the end of str[].
Most of the regulars here don't reply to private messages and prefer to answer questions directly on the forum simply because if we make a mistake, somebody else will spot that and correct it.
I never ever make mistakes :) I was wrong only once in my life, that when the time I thought I was wrong, but I was wrong about that.
I've never done it quite like that, so I don't know if it will work or not. But you never called CreateMutex() andwhere. I would put it in mainClass() before anything else.
>>what is the logic behind initializing inner loop variable j=i+1 instead of j=0???
which post # are you talking about?
>>If the larger number is odd,
what happens if the larger number is even ?
line 71 needs to be delete[] temp;
Please don't create a new thread just to rant about something.
I don't drink coffee -- no option for that either, so I stopped at the first question.
It doesn't work because on line 7 the array is treated as a pointer, and the size of all pointers in 32-bit compilers is 4. If you want myfunc() to know the size of the array then it will have to be passed as another argument. void myfunc(const Car A[], int size)
you must be running *nix because MS-Windows doesn't have such a command. kill -9 123
where 123 is the pid of the running process.
You don't pass it at all. Typically the thread would call CreateMutex() to get a handle to the mutex object, then WaitForSingleObject() to gain access
// This goes in each of the two threads
HANDLE hMutex = CreateMutex(0, FALSE, "MyMutexObject");
if( hMutex )
{
// wait for access
WaitForSingleObject(hMutex);
// do whatever work needs to be done goes here
//
// release the mutex to other threads
ReleaseMutex(hMutex);
}
make the arrays float instead of int. ifstream is producing an error attempting to convert that decimal point to an int.
Hi! can someone tell me how to count the number of lines?
I suppose you mean the number of lines in a file??? create an int variable and initialize it to 0. Open the file. Set up a loop to read the file one line at a time using getline() then increment the counter variable on each loop iteration.
setw() tells cout the minimum width of a column. When the actual text is longer than that cout will just ignore the setw() value. So make the columns wide enough to hold the longest line plus a few spaces for best looking product. Also use left to left-justify the text in the space.
Try this simple example and see how it looks:
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << left << setw(20) << "Hello" << "World\n";
}
Its not in the registry, but maintained on a clock cpu chip. This is how to synchronize network computers.
>> while( ch1 != EOF ){
That won't work because (1) ch1 must be an integer, not char and (2) EOF is not known until it attempts to read beyond end-of-file, not before.
Don't read the file one character at a time, but one line at a time. Use fgets() to read each line, then compare them using strcmp().
Line 19 does not satisfy the requirements of the program because you also have to print out all the line numbers that do not match. That means you have to keep track of line numbers -- fgets() will help make that very easy because all you have to do is increment a counter each time fgets() is called. If the two lines are not the same then just display the line number and continue on reading the files.
I could post some code, but then I'd ruin the fun you will have of completing the assignment :)
MS Access is not a good choice for large databases. Move on to something else, such as MySQL, Sybase, or Microsoft SQL Server. I don't know what the max size is of their databases but I know they are better than Access. So I would not ask M$ to increase Access's file size because it won't make a bad database any better.
It might help understand the problem if you would post an actual example of the buffer.
all versions of vc have the same default.
You are probably using VC++ 2008 Express, which by default compiles everything for UNICODE. You have two choices:
(1) Turn UNICODE off. Projecct --> Properties --> Configuration Properties --> General. In the controls shown in the right-hand side of the screen look for "Character Set" (3d from the bottom) and change it to "Not set".
(2) Make the string UNICODE _TEXT("calc.exe")
You could shift everything after "Happy" left 5 positions to overwrite that text, which will move the empty spaces to the end of the buffer. Since its a binary buffer (I think it is anyway from your description) you can fill the remaining bytes with '\0'.
So if the buffer looks like this: "Don't Play with MemoryHappyxxxxyyyzzz"
you would shift "xxyyyzzz" left to overwrite Happy so that it winds up looking like this Don't Play with Memoryxxxyyyzzz'\0''\0''\0''\0''\0'"
After that you could call realloc() to resize the buffer or just leave it alone.
um well i don't see what part of "keep it legal" a process injection script is breaking. this section talks about copyrights, pornography, and not posting pirated software.
Don't worry -- IMO you are not violating that rule (yet).
and line 27 would be
hNewModule = VirtualAllocEx(hProcess, hModule, dwSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
As I stated previously, just typecast the return value to HMODULE and it will compile just fine.
You will have to lock the queue in order to synchronize the two threads. Disaster will strike your program dead if you allow multiple threads to access a single common object without first locking them. One way to do it is use mutex's. The main thread should create a named mutex so that other threads can attempt to access it. The os will only allow one thread at a time to access the mutex -- all other threads are blocked until the current thread releases the mutex.
Here is an article for MS-Windows mutex.
c++ is a lot stricter about typcasting than C. For example, in C it is not necessary to typecase the return value of malloc(), but in C++ it is required.
Which one of the lines you posted is line 27?
just use two (or more) case statements with no break in between
switch(keycode){
case DOWN :
case TAB:
if(edtIndex == editSize - 1){
fieldPos = edtList[0];
edtIndex = 0;
}
else if(edtIndex < editSize - 1)
fieldPos = edtList[++edtIndex];
break;
}
The problem with using the system() functions to do a lot of things is that whever you wanted it to do just disappears as soon as the system() function finishes. For example: lets say you want to change directories to c:\windows so you issue the command system(cd c:\\windows");
The system() function will execute the dos command, but as soon as system() returns to your program the program's current working directory will not have changed. To make such a command permanent in your program, it needs to issue equivalent C functions, in this case _chdir("c:\\windows");
depends on your version of windows. But why would you want to do that anyway? With Vista just copy it to here: C:\Users\<your login name here>\Desktop
Mozart Chamber Music.
Right now -- popcorn. Just finished bowl of Silk Soy Milk and cereal.
you mean the one with the bionic woman as well?
Yes
The idea of sharp objects down there doesnt appeal to me
Not pleasant, but not all that bad either. And makes sex even better than before because there is no concern about pregnancies.
thank you all for your contributions, i need to know how to make numbers appear as asterisks e.g 123456 comes out like (******)
Vasectomy is an excellent method of birth control, assuming one's religion doesn't get involved. But I would never recommend it for any man with less than two children.
From the code you posted in #11 above:
line 27: delete that line because it is causing the program to read twice. The data was already read on line 25 in the for loop.
mitrmkar - Red bar while compiling on line:
if(!ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER))
I think it is the compiler?
Anyone else using codeblocks?
It always used to work?
Maybe needs a plugin or something similar?*RAWR* this is doing my head in :|
Did your compiler give you an error message? If yes, what was it?
Did you #include <windows.h>
? Does your compiler know where windows.h is installed?
cin won't allow alpha characters to be entered into numeric fields. So when you have cin >> num1
num1 will NEVER have 'x' or 'X'.
What I would do is get input data as strings so that you can easily determine if the input character is 'X'. Something like this:
std::string input1, input2;
cout << "Enter x to exit the program early." << endl;
cout << "Please enter a numerator and a denominator for each fraction. ";
cin >> input1 >> input2;
if( input1.length() > 0 && input2.length() > 0)
{
if( input1[0] == 'X' || input2[0] == 'X')
{
}
// validate input is all numeric digits
//
//
// convert to integers
num1 = atol(input1.c_str());
num2 = atol(input2.c_str());
// blabla
}
I am administrator, so... lol
Ancient Dragon did u use C++ code for that line of code or just run it in cmd? cause my cmd works fine cant get anything working through C++.
I ran it as a c++ program. If it doesn't work for you then probably a difference in the way our computers are set up. For example, I've turned off the User Account Control because I hated all those security questions every time I wanted to do something.,
I'm using VC++ 2008 Express and I had to change the resource.h file as shown below. Make sure there is a '\n' after the last line or the resource compiler will complain.
#ifndef APSTUDIO_INVOKED
#define IDR_MYMENU 101
#define IDI_MYICON 201
#define ID_FILE_NEW 1001
#define ID_FILE_OPEN 1002
#define ID_FILE_SAVE 1003
#define ID_FILE_EXIT 1004
#define ID_EDIT_CUT 2005
#define ID_EDIT_COPY 2006
#define ID_EDIT_PASTE 2007
#endif
Then you have a typo in the resource.rc file.
I think the user will have to be logged in under an Administrative account for that to work. In school users probably don't have those permissions, and there is nothing you can do about it short of getting the instructor to let you log in as Administrator (and that's highly unlikely)
you can assign any number you want, as long as all the numbers in the RC file are unique. Put a lot of space between control types, such as start icons with 100, menus with 200, dialogs with 1000, etc. The reason is to make it easy to add new items of the same type without having to renumber everything and still keep the numbers organized by type.
check spelling and capitalization!
Read the tutorial and it will tell you how to do it!
You really should get a GUI resource editor so that you can create dialogs and associated controls graphically.
cin.clear() doesn't flush the input stream -- just clears some of cin's error flags which is entirely a different animal. Re-read the article, don't just glance over it or you will miss it.
The differences can also be just a colloquialism or dialect. There are many differences in the way the Brits and Americans speak -- hell there are differences among Americans.
You will need to make the first field in each record the auto-generated number. Then when you need another number, just read the last record in the file and increment the number to get the next number.
If the database is going to be fairly small you can just read the entire file into memory when the program starts so that you don't have to read it so many times. Read each record and put them into an array, or a vector. That will make it easy to get the next auto-generated number.
When the error occurs you need to flush the input buffer of all remaining characters. Narue has written an excellent article about flushing the input buffer here.