|
Have a look at the locale functions, such as isalpha() and isalnum() here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
isprint [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I need toi create the slider control in the shape of circle.
|
|
|
|
|
Does this help?[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
|
how can i set button size according to text size dynamically, means in run time text of button is changed using setwindowtext() method but size of button remain static either text is small or larger so how to fix it,
pls help
|
|
|
|
|
use SetWindowPos() or MoveWindow() function to resize the button. To find out how much length a text takes, use the CDC::GetTextExtent() function or CDC::DrawText() function.
|
|
|
|
|
thanks for da reply but will u plz send me code using these methods as never used before
|
|
|
|
|
ani_ikram wrote: u plz send me code using these methods as never used before
So you dont want to learn vc++?
Check the MSDN for the help of each function, do some sample and ask us if you face some problem while using that functions. Those functions are really easy to understand. Give a try..
|
|
|
|
|
Its not hard you need to a handle to your button.
|
|
|
|
|
Hello I still am having this sscanf problem, last topic died out.. there is no bump feature so I have to post a new one. SIGHS
Anyways as the post was..
struct Pos {
int x
int y
};
char line[66] = "spawn = 1648\t3411\t3536\t0\t3412\t3537\t3410\t3510\t2\tCRAWLING HAND\0";
int npcId;
Pos coords;
int heightLevel = 0;
Pos moveRange1;
Pos moveRange2;
int direction;
sscanf(line,"spawn%*[ ]=%*[ ]%d%*[\t]%d%*[\t]%d",&npcId, &coords.x, &coords.y);
printf("npcID = %d\n", npcId);
printf("coords x = %d\n", coords.x);
printf("coords y = %d\n", coords.y);
sscanf(line,"spawn%*[ ]=%*[ ]%d%*[\t]%d%*[\t]%d",&npcId, &coords.x);
printf("npcID = %d\n", npcId);
printf("coords x = %d\n", coords.x);
printf("coords y = %d\n", coords.y);
I need to parse threw the line and get all parameters.. getting the first 2
npcId and coords.x works fine.. but the more I add sooner or later the first one npcId starts to fail... but coords.x doesn't fail. can someone tell me whats wrong in this strange behavior
|
|
|
|
|
Cbadboy wrote: Hello I still am having this sscanf problem, last topic died out...
Because it was found to work as expected here.
Cbadboy wrote: sscanf(line,"spawn%*[ ]=%*[ ]%d%*[\t]%d%*[\t]%d",&npcId, &coords.x); //* = ignore
You are missing an int argument to sscanf() . The result is that it sees the last %d and is popping an extra int from the stack.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
man???
the one thats missing was missing on PURPOSE and it works.. but when I add the non-missing ones.. as you see above.. are not missing that doesn't work!
something to do with structs and sscanf()
|
|
|
|
|
Cbadboy wrote: the one thats missing was missing on PURPOSE and it works...
Actually it only appears to work. Errors don't cease to exist just because printf() happens to print the right value. The stack is still being popped incorrectly, it just happens to be popping off something that is of less importance. Use the debugger, not the output from printf() , to determine your program's correctness.
Cbadboy wrote: something to do with structs...
Nothing to do with that at all.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hello again everyone. I appreciate the helped that I received last time but I need help again on my array programs. I was wondering if some one could tell me how to set up my arrays for the following programs I would greatly appreciate it.
Here are the instructions:
1. Grade Book
Create a New Project called YourLastnameGradeBook.
A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores.
Test Score Letter Grade
90-100 A
80-89 B
70-79 C
60-69 D
0-59 F
Write a program that uses a two-dimensional array of characters to hold the five student names, a single-dimensional array of five characters to hold the five students’ letter grade, and five singe-dimensional arrays of four doubles to hold each student’s set of test scores.
The program should allow the user to enter each student’s name and his or her four test scores. It should then calculate and display each student’s average test score and a letter grade based on the average.
Input validation: Do not accept test scores less than 0 or greater than 100.
2. Payroll
Create a New Project called YourLastnamePayroll.
Write a program that uses the following arrays:
· empId: an array of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers:
5658845 4520125 7895122 8777541 8451277 1302850 7580489
· hours: an array of seven integers to hold the number of hours worked by each employee
· payRate: an array of seven doubles to hold each employee’s hourly pay rate
· wages: an array of seven doubles to hold each employee’s gross wages
The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by the employee whose identification number is stored in element 0 of the empId array. That same employee’s pay rate should be stored in element 0 of the payRate array.
The program should display each employee number and ask the user to enter that employee’s hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate) and store them in the wages array. After the data has been entered for all the employees, the program should display each employee’s identification number and gross wages.
Input Validation: Do not accept negative values for hours or numbers less than 6.00 for pay rate.
3. 2D Array Operations
Create a New Project called YourLastname2DArrays.
Write a program that creates a two-dimensional array initialized with test data. To simplify this, make all of your data integers. The program should have the following functions:
· getTotal. This function should accept a two-dimensional array as its argument and return the total of all the values in the array.
· getAverage. This function should accept a two-dimensional array as its argument and return the average of all the values in the array.
· getRowTotal. This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row.
· getColumnTotal. This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column.
· getHighestInRow. This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the highest value in the specified row of the array.
· getLowestInRow. This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the lowest value in the specified row of the array.
Demonstrate each of the functions in this program.
|
|
|
|
|
You're a persistent fella, aren't you?
LilKoopa wrote: I appreciate the helped that I received last time
You didn't receive any help. You received sarcastic comments and were directed to the forum guidelines. Try to figure out why and then do your homework.
Edit: I just realised that you weren't directed to the forum guidelines. So, here you go:
http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=1278597[^]
modified on Friday, October 10, 2008 5:14 AM
|
|
|
|
|
its done now I just wanted to know if somebody would show me how to initialize the arrays because my book didnt do a really good job explaining it to me.
|
|
|
|
|
LilKoopa wrote: Write a program that uses a two-dimensional array of characters to hold the five student names, a single-dimensional array of five characters to hold the five students’ letter grade, and five singe-dimensional arrays of four doubles to hold each student’s set of test scores.
That is really very basic stuff. Try to write some code and post a question whenever you meet the first obstacle.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
LilKoopa wrote: Create a New Project called YourLastnameGradeBook.
Have you done this?
LilKoopa wrote: Write a program that uses a two-dimensional array of characters to hold the five student names
This approach is potentialy unsafe and not necessary with C++. For example:
vector<string> names;
string name;
for (int x = 0; x < 5; x++)
{
cout << "Enter name #" << x + 1 << ": ";
cin >> name;
names.push_back(name);
}
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
This is a niggling little cosmetic issue that I thought would be easy to solve with a bit of message manipulation. It is turning out to be unreasonably difficult.
I have a combobox on a toolbar (as part of the Objective Studio framework) and I have filled it with a fixed set of 'menu like' contents (it actually echos a dynamic menu in the app).
a la...
Title 1
- Entry 11
- Entry 12
- Entry 13
Title 2
- Entry 21
- Entry 22
What I wanted to do, when an Entry is selected, was to automatically remove the ' - ' at the start of the string.
So I used the CBS_DROPDOWN style (instead of the CBS_DROPDOWNLIST) so I could 'edit' the contents of the selection, while using PreTranslateMessage to prevent keyboard edits. I then caught the CBN_SELCHANGE event, from which I can get the current selection, edit the text and then SetWindowText. This all works, but occurs BEFORE the combo box edit control updates, meaning the Entry is set back to list value (with the ' - '). I need a CBN event after update, but their isn't one.
Any suggestions? I don't really want to go so far as deriving a new control to solve this minor issue, but it is bugging me a bit.
|
|
|
|
|
OK...I solved this with what seems like an ugly hack, surely there must be a better way....
Anyways, what I did was to PostMessage a user message from the CBN_SELCHANGE event and strip the prefix in my user message handler, I just hope the messages continue to arrive in the correct order...
|
|
|
|
|
I used NtQueryInformationProcess to get
PROCESS_BASIC_INFORMATION and PEB and then RTL_USER_PROCESS_PARAMETERS.
But CommandLine of RTL_USER_PROCESS_PARAMETERS is always associated with the currect process although I passed in different PID into NtQueryInformationProcess() call.
By the way, I am using XP64.
Can you help.
Thanks
Jack Rong
|
|
|
|
|
Have you read the following notice in documentation [^]:
[NtQueryInformationProcess may be altered or unavailable in future versions of Windows. Applications should use the alternate functions listed in this topic.]
?
Jack Rong wrote: although I passed in different PID into NtQueryInformationProcess() call.
You should pass the process handle, shouldn't you?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for your response.
Yes, I do pass the process handle, here is the example,
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE, mypid );
NtQueryInformationProcess (hProcess, ProcessBasicInformation,
&pbi, sizeof(pbi), &dwSize);
Where "mypid" is what I want and is not current PID. But the CommandLine I got is the Current Process's CommandLine. So strange!
Yes, I realize that. But I am not sure which new function can be used in order to replace the "NtQueryInformationProcess()" though.
Jack
|
|
|
|