|
I understand but why does the compiler reference CStringT
When I used the CString object
|
|
|
|
|
CString is simply a typedef of CStringT. CStringT is derived from CSimpleString. This combination allows various encoding methods to be used with the same code. Thus you have CStringA (using char) and CStringW (using wchar_t) as basic types. In theory you could create even more types by using the templates and adding you own helper classes.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
So ....CStringT is for regular excuse the term string char
as opposed to Unicode
The members of CString are really in AFX.H were Cstring is defined
|
|
|
|
|
No, CStringT is a template class that allows you to instantiate a string class that uses ANSI, UNICODE or whatever encoding scheme you want to try.
CString is a typedef of CStringT. The typedef for CString is NOT defined in afx.h. As far as I can tell, you are confusing VC++ 6.0 and VS 2005/2008.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
You could be right thr AFX.H member where I found CString
Was in my Platfork SDK folder
Not in the VC folder (Part of Visual Studio SubDir)
Thankx
|
|
|
|
|
Do NOT use any MFC from a platform SDK. You shouldn't even be referencing such an outdated SDK in VS 2005/2008 since it will cause other frustrations. (I rarely use the Platform SDK and when I do, I always install it in a Virtual PC, clean out the dross and then copy the directories out and then only use it by specific reference in the a project file.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
thankx
I dont know if you do this for a Living but I work as MainFrame
programmer this is a new of thinking for me
thankx again
|
|
|
|
|
Ok Im trying to start this problem off but i have no idea where to start off i was wondering if someone could break it down for me.
A voltage source supplies a load through a resistor. The
voltage source has a rating of 1000 volts and a power rating
of 10000 watts. The resistor is 5 ohms with a power ratings
of 118.975 watts. The resistance of the load may vary
randomly between 200 and 600 ohms. Using 100000 samples
calculate the I have to find the number of times the power rating of the resistor is exceeded,average power delivered by source, maximum power delivered by source,and the minimum power delivered by source
|
|
|
|
|
AFAIK VC++ stands for Visual C++ , not for Voltage Computing++ ...
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]
|
|
|
|
|
brains89 wrote: 1000 volts
Hey dude! your question has nothing to do with programming. Take your question to appropriate forum before someone zaps you with 1000 volts rod.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
I have to do this using C++, so i think i have the appropriate forum
|
|
|
|
|
yes you could do it in C++. There is nothing that will prevent you. But your question does not have any slight hint of programming.
Heck, during my days of Electronics classes, we did it using paper and pencil. How is that for programming
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Wow, paper and pencil...100000 samples...how long did your Electronics course take?
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'm still working on it. now calculating sample 250 of 100000
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
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]
|
|
|
|
|
Having the sample count already specified implies this is a homework question, but I'll try to give as many hints as I can without ruining it for your learning...
1/ To start with, this isn't a C specific question, but there's nothing stopping you doing this in C. You could do it in fortran, c#; heck, I'd probably recommend using excel...
2/ Your initial problem is solving the equation on pen and paper.
(Yes, I know you have a thing that varies - remember your algebra)
volts = current * resistance
power = current * volts
current = volts / resistance.
I'd suggest excel to start with, or a simple MFC dialog application with a box you type in a user supplied resistance value, and then spit out the results you care about to test your equation.
4/ Now move on to the second part of the question, the varying resistor.
4a/ What is the probability curve? Even if you assume it's flat, you should document that assumption. Why is it varying? If it's a toddler playing with a knob, it may be a guaussing distribution. The point is that it's not specified, so you either have to ask, or at least spell out your assumption.
4b/ Look up Monte Carlo Simulation - I bet it's what you've been taught. Run your function 100000 times with a random number between 200 and 600 and pop the results into a huge table.
4c/ Whether you write them to a text file, and import that into excel, or add a pretty graphic control (we have them here on CP) is up to you.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
i am having a grid control in which i did some masking for 10 characters. But if i enter some less characters then it appends underscore character to the end which i dont need. Please provide comments.
|
|
|
|
|
show us how your are masking your string
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
The short answer: Just remove the characters that you don't need.
The answer: Read the sticky post at the top of this forum. Provide more information that will let us give you a helpful answer.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
pandit84 wrote: i am having a grid control in which i did some masking for 10 characters. But if i enter some less characters then it appends underscore character to the end which i dont need. Please provide comments.
Comment no.1: "Uh, what an interesting post".
Comment no.2: "Apparently, the grid control doesn't fit you needs".
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]
|
|
|
|
|
When I try to compile my code I get this error message:
@: gcc -o hw3 hw3.c
hw3.c: In function `main':
hw3.c:20: parse error before `char'
hw3.c:31: `buff' undeclared (first use in this function)
hw3.c:31: (Each undeclared identifier is reported only once
hw3.c:31: for each function it appears in.)
The error occurs because of my if statement.
When I place the if statement after the char declaration it works, also when I remove the if statement it compiles and works fine.
if(argc == 1){
printf("Error: hw3 <buffersize>");
return 1;
}
Also for a plain "if(){}" as well.
How do I get around this?
#include
#include
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char * argv[])
{
int fileread, filewrite;
ssize_t nread, nwrite;
if(argc == 1){
printf("Error: hw3 <buffersize>");
return 1;
}
char buff[ (int)argv[2] ];
fileread = open("128kB.bmp", O_RDONLY);
filewrite = creat("copy.bmp", O_WRONLY);
while(1)
{
nread = read(fileread, buff, sizeof(buff) );
if (nread == 0) break;
nwrite = write(filewrite, buff, sizeof(buff) - 1 );
}
close(fileread);
close(filewrite);
return 0;
}</buffersize></stdio.h></fcntl.h>
I am using a putty terminal connected to a unix machine.
|
|
|
|
|
Endomlic wrote: When I place the if statement after the char declaration it works
Then, why not do it that way?
I reckon good old C compilers expect you to declare all the variables used in a a function at the very beginning of the function block and not anywhere in between. I also think that more recent versions of C compilers allow this.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
If I declare the char beforehand then I can't use the if statement as intended.
I need to see if they actually entered a buffer size, if not then the program will crash with the wrong error message I want displayed.
That's where the if statement comes in. The if will break the program if they do not specify a buffer size. and if they do then it will be used as the char buff array size.
How else can I declare a char buffer size and change it after the if?
|
|
|
|
|
Endomlic wrote: How else can I declare a char buffer size and change it after the if?
Declaring it as a pointer variable prior to the if statement, and doing dynamic memory allocation later sounds like a viable option?
Or may be switch to a more recent version of the compiler that supports declaring variables anywhere.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Endomlic wrote: char buff[ (int)argv[2] ];
1. You are trying to create buffer dynamically. -Without specifying a constant value for memory allocation. It requires you to use "new".
2. Use atoi to convert argv[2] to an int value. You cannot just cast like that.
Example:
char* buff = new char[atoi(argv[2])];
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|