|
There's not going to be all that simple an answer for you. What you are asking for is the stuff you learn in a lesson, or from a book - not from a quick post.
But here's a start.
char means char acter. In those other languages, "Hello" is a string, not a char either.
Another work for character is letter. So, 'H' is a char, "Hello" is a string, or bunch of characters one after another.
char message [] = "Hello";
That means that the message variable is an arrach of characters - or an array of letters. In this case, 'H' followed by 'e', 'l', 'l', 'o', and lastly a char value of 0, to denote the end of a string.
And that's all I'll reply - otherwise I'll write a book for you - and other people have already done that.
But hopefully ot will get you started on your journey.
I learned from Kernigan & Richie - small language, small book.
Now, if you want to *pay* me to write you a book...
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
egerving wrote: if you define char x[112] you then can't say x="Hello" because I guess x must be 112 chacters
No - it's because a C string, when referred to by name, is a pointer, not an array. You can use strcpy and strcat (and many other functions) to build strings.
For your situation, I'd probably use fprintf to write each record to the file, using width specifications - something like:
fprintf(fileHandle, "%-2d%-4d/%-2d/%-2d%-2d%-2d:%-2d%-20s %-1d%-11.2f%-11d%%-10d\n", firstCode, year, month, day, hour, minute, second, barcode, secondCode, decimal, firstNumber, secondNumber);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
egerving wrote: ...and if you define char x[112] you then can't say x="Hello" because I guess x must be 112 chacters.
Valid:
char x[112] = "Hello"; Invalid:
char x[112];
x = "Hello";
egerving wrote: ...if you want use a variable and assign it to different values and/or concatenat different values to it what do you do.
For C, use functions like strcpy() and strcat() . For C++, use the string class.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thank you all very much for your posts. Every little bit helps. I think I'm really starting to like this site as this is the second time I've made a post and got responses both times!
Thank you.
|
|
|
|
|
One thing to understand is that in ALL languages a character is a number. With C/C++ it's just more obvious about it. In pure C/C++ and Assembly, you are simply doing manually what high level languages do behind your back. (With CString and string in C++, you can also treat strings as "abstract" objects.)
* * *
For the text file question, look at cout , and its cousins, though I vastly prefer printf()/fprintf() and its cousins.
printf("%02d%04d/%02d/%02d%02d:%02d:%02d and so on
(One variant of this is printf("%.2d%.4d/%.2d/%.2d%.2d:%.2d:%.2d . I prefer the former, but you will run into the latter and should be aware of it.)
|
|
|
|
|
I need to remove security descriptors from certain registry keys.
What functions would be of interest for this operation?
( The problem is that even the administrator is being denied access to change key values, and I am going to try to manually remove all descriptors, hoping that this might fix it. )
|
|
|
|
|
Seems unlikely that'll work - you'll get 'access denied' status returns, I would have thought.
However, I think these should be of use - GetNamedSecurityInfo[^] to retrieve something's ACL, SetEntriesInAcl[^] to create a new ACL from that ACL, DeleteAce[^] to delete an ACE from an ACL and SetNamedSecurityInfo[^] to set the new ACL on the object.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for the information.
|
|
|
|
|
|
Thanks very much for those links. I'll read them carefully.
|
|
|
|
|
Hi All
i am posting one url with setting this "x-microsoftajax;Delta=true" header but i am getting "400" http error code, can someone please give me suggestions on it.....
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Can anybody tell my why MDI framework do not cross over through OnActivateFrame(int nCmdShow) ? I build a MDI test application ( doesn't matter CView based on ) and I override CMainFrame::OnActivateFrame(int nCmdShow) where I put a TRACE0("\n Here cross over OnActivateFrame \n"); statement and compile in Debug version , but Output window doesn't show anything ... can you tell my why ?I mention that SDI framework haven't this problem ...And for what I need that handler : to memorate window position ...
|
|
|
|
|
OnActivateFrame is an overridable method of CView, NOT the frame window class.
You may find OnActivate is the overridable method you're look for.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Good catch ! And in case that I not load a child window like this :
if(CCommandLineInfo::FileNew == cmdInfo.m_nShellCommand)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
where should I load WINDOWPLACEMENT structure ? Anyway , thanks for answer !!
|
|
|
|
|
In the main frame's OnCreate, after you've called the base classes OnCreate handler, I would have thought.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Ok, I will try that , and let you now what I settle down ... thanks again !
|
|
|
|
|
Hello,
When I enter the left arrow key or the right arrow key nChar = 39 or 38 for the OnKeyDown() but nChar = 13 for OnKeyUp()
void CRICH::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
}
void CRICH::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
}
Why there is a change in nChar value for both the functions
Thanks
Pritha
|
|
|
|
|
What view base class were you using? It's entirely possible that the base class could be using PreTranslateMessage or something to alter the OnKeyUp handler?
I tried this with a view class derived from CView and the character code was always the same in OnKeyUp as in OnKeyDown.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hey thanks
But can you please tell me what is the use of PretranslateMessage(). I searched for it but didnt get any proper answer.
Pritha
|
|
|
|
|
See the documentation[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Dear all,
I am facing quite an annoying problem I can't solve. I have a std::valarray<MyT>, where MyT can be anything, and I need slices of it to work locally on them.
If the elements MyT contained in the valarray are big (not to say HUGE), the usage of std::slice is quite inconvenient, since temporary copies of the objects are created in the slice.
Same problem in case MyT is small (let's say MyT = int), but the slice contains a large number of elements, let's say 1e4 or 1e5.
An approach using references would be much more efficient than std::slice in my opinion (+ it would allow to modify the elements contained into the valarray), but I don't know how to implement an object like this. The only alternative to that I have in mind is to use std::valarray<T*>, but I don't really like the pointer syntax and I'd prefer to avoid it.
Any suggestions, please?
Thank you in advance to anybody willing to help & best regards
|
|
|
|
|
What specific capabilities of valarray are you using that make you prefer it to std::vector? Because I'd tend to prefer using std::vector (which is, post-TR1, guaranteed to store its data as an array) and represent slices as pairs of iterators.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, from some performance test I made quite a while ago (using MSVC++ 2005) I noticed that reading/writing into a std::valarray was quite noticeably faster than using std::vector. Since I am working on a numeric application which has to handle quite large amounts of data, the fastest container seems the most natural choice. Apart from execution time, there are no other reasons.
Shall I re-run my performance test using a compiler better than MSVC++ 2005?
Stuart Dootson wrote:
using std::vector (which is, post-TR1, guaranteed to store its data as an array)
What does this sentence exactly mean? What would happen scanning a pre-TR1 std::vector with an iterator? Or, perhaps worst, using pointers? Access to wrong memory places?
Thanks a lot for your suggestions!
|
|
|
|
|