|
Taken from K&R 1st ed? Certainly has that feel>
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
It is the Wonderful C programming language, of course has such a feel.
In any case, were Dennis and Brian the ones who plagiarized my programs. 
|
|
|
|
|
I was begging to think no one here was thinking.
Thanks
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
I have copied a program from CrazyGeeks website and modified some of its statements. Anyone please tell me whats wrong in below code:
#include <iostream>
using namespace std;
int main()
{
int count, j, elements[50], search_num, first, last, mid;
cout<<"Enter the total number of elements :";
cin>>count;
cout<<"\nEnter ">>count>>" numbers:\n";
for (j=0; j<count; j++)
{
cin>>elements[j];
}
cout<<"\nWhich number that you want to search: ";
cin>>search_num;
first = 0;
last = count-1;
mid = (first+last)/2;
while (first <= last)
{
if(elements[mid] > search_num){
first = mid + 1;
}
else if(elements[mid] == search_num){
cout<<search_num<<" found in array at "<<mid+1<<"\n";
break;
}
else {
last = mid - 1;
}
mid = (first + last)/2;
}
if(first > last){
cout<<search_num<<" Not found in an array";
}
return 0;
}
Code link
|
|
|
|
|
Quote: cout<<"\nEnter ">>count>>" numbers:\n";
Should be
out << "\nEnter " << count << " numbers:\n";
You should ask the user for an ordered sequence, in order to make the binary search work.
Your code is very C -like, you didn't take advantange of the wonderful features of modern C++ . 
|
|
|
|
|
|
|
You should format your code snippet with the proper indentations.
|
|
|
|
|
Hi!
I am currently working on a project that is used to the global event.
I did not find any vague suggestions on google.
Show me how to start it and document it.
Thank you!
|
|
|
|
|
I'm having diffculty to understand what you're looking for, and I suspect for google it's the same.
Let's start with specifiying more clearly what you want to do:
- what is a typical usecase for the program that you want to solve?
- what are the conditions under which the program is used?
- who uses the program?
- who writes the program (other than you)?
And more to the point:
- what do you mean by global event?
- what do you mean by 'start' and 'document' and 'it'
I do have some ideas what you're talking about, but it would be easier to offer meaningful advice when there's less guessing involved.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Thanks for your answer!
I'm looking to build a demo to use to the global event.
I want to write a program (MainApp) that manages two other programs (SubApp1 and SubApp2). When I run MainApp, then MainApp will start subapp1 and subapp2.
|
|
|
|
|
1. You still haven't told us what you mean by global event
2. You're talking about processes and threads. Typically when you start an application on your computer, this starts a process with a single thread, the main thread. You can choose to leave it at that, in which case your program will just sequentially process it's task. Or your process can create new threads controlled by it, which will potentially run in parallel. You can also start a new process from the first one, but then your initital process will have no direct control over it; it can only talk to it via interprocess communication protocols.
In that latter case, communication might be implemented by sending Windows Events to the other process. I'm sure there are many other ways, but I'm not up to date with modern approaches in this field, nor do I have any relevant experience.
So, when you talk a 'mainapp' and 'subapp's, do you mean a process and it's threads, or do you mean to spawn separate processes - in which case the term 'subapp' would be very misleading?
P.S.: I only now spotted your answers below - looks like I was on the wrong path all along. As CPallini said, you'd better ask at the Kentico forums. And as they're using C#, the question is if you really want to go the extra mile of trying this in C++ ...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Thank you very much for your support!
|
|
|
|
|
What event your are talking about?
Event Objects[^], for instance, as far as I know, are not globals.
|
|
|
|
|
|
You should have mentioned you were using Kentico12. Probably you need to ask the question here: Questions & Answers[^].
In any case it looks .NET stuff, not C++ .
|
|
|
|
|
|
|
I took a quick glance at the Kentico site. Now I know this is about designing web pages - another bit of information you could have shared from the start.
One thing however is important to know: on it's main page[^] Kentico states (under "Disadvantages") that itQuote: Requires knowledge of ASP.NET MVC and programming. This doesn't sound like a beginner's tool to me. If you don't already know ASP.NET, this will be a stony path...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I am trying to open any kind of file using
ShellExecute(NULL, _T("open"), sPath + _T("\\") + sText, NULL, NULL, SW_SHOWNORMAL);
and is working well, but there a little issue: when I am trying to open an image file, I get always the "How do you want to open this file" dialog, everytime … why ? Of course, when I am trying to open this kind of image file from y windows explorer, is open with my default program, Windows Photo Viewer.
Is there any kind of parameters to put on ShellExecute ? Please note that I use this for ever kind of file, including exe files.
|
|
|
|
|
Go to Windows Explorer, right click on one of the files with that type, and check its properties.
|
|
|
|
|
I check it, there is no any problem, it is open properly in windows explorer … not in my app, using ShellExecute …
|
|
|
|
|
Have you checked that the details in the properties for open refer to the absolute path to your application? What is the return value from ShellExecute when you run the code? What are the values of sPath and sText ?
|
|
|
|
|
|
I have tried:
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (SUCCEEDED(hr))
{
HINSTANCE hInstance = ShellExecute(AfxGetMainWnd()->GetSafeHwnd(), NULL, sPath + _T("\\") + sText, NULL, NULL, SW_SHOWNORMAL);
if (reinterpret_cast<int>(hInstance) <= 32) ::SendMessage(theApp.m_pMainWnd->GetSafeHwnd(), WM_SETMESSAGESTRING, 0, (LPARAM)(LPCTSTR)GetDocument()->FormatHinstance(hInstance));
}
the same result ...
|
|
|
|