|
venkatesh52867 wrote: these methods not calling please check my class Please do not do this, we cannot go through something like the above trying to figure out what is happening. Use your debugger to narrow down the problem area and post some more specific detail.
Use the best guess
|
|
|
|
|
Hi guys please I need your help to do a little code at the green comment line in order to do this:
when I try to add new element to an array
4 56 7 10
like 100 at 1 index position
will do this
4 100 7 10 56
it should be like this :
4 100 56 7 10
so the problem is i have to use swap making swap variable take value and them move the rest on order to make like this
4 100 56 7 10
#include<iostream >
using namespace std;
void printarray(int [], int,int );
void gradefull( int [],int ,int&);
void add(int [],int ,int) ;
void main(){
int * gradeArray;
int g;
int elmentnumber=0;
cout<<endl;
cout << "\tEnter the number of elemetn for the array: " ;
cin>>g;
gradeArray=new int[g];
gradefull(gradeArray,g,elmentnumber);
cout << endl ;
printarray(gradeArray,g,elmentnumber);
cout << endl<< endl ;
cout<<"Adding New Element:"<<endl<<endl;
add( gradeArray , elmentnumber,g);
cout << endl<< endl ;
system("pause");
}
void gradefull( int gradeArray[],int g,int & elmentnumber ){
cout<<endl;
for ( int i=0;i<g; i++ ){
int input;
cout << "please insert the element #<"<< i<<">: ";
cin>>input;
gradeArray[i]=input;
elmentnumber++;
}
}
void printarray(int gradeArray[], int g,int elmentnumber){
for ( int i=0;i<g; i++ ){
cout<<"\t"<<gradeArray[i] <<" ";
}
cout<<endl;
cout<<endl <<"\tYou entred <"<<elmentnumber << "> elments";
}
void add(int gradeArray [],int elmentnumber,int g ){
int temp;
elmentnumber++;
int newinput;
int indix;
cout<<endl;
cout<<" Please Enter the postion indix for the new element: ";
cin>>indix;
while((indix>elmentnumber)||(indix==elmentnumber)){
cout<<" Please Enter the postion indix for the new element: ";
cin>>indix;
}
for ( int i=0;i<elmentnumber; i++ ){
if ( i==indix){
temp=gradeArray[i];
cout<<endl<<"\tEnter the new element number: ";
cin>>newinput;
gradeArray[i]=newinput;
}
} cout<<endl;
cout<<" The new Array after Adding the New element: "<<endl<<endl;
if (indix<g){
gradeArray[elmentnumber-1]=temp ;
}
for ( int i=0;i<elmentnumber; i++ ){
cout<<"\t"<<gradeArray[i] <<" ";
}
}
modified 4-Mar-13 5:21am.
|
|
|
|
|
How could you possibly insert insert a new element without growing the array?
Have you thought about it?
By the way, do you know STL provides the vector container, that in turn provides the insert[^] method?
Veni, vidi, vici.
|
|
|
|
|
Your code does not adjust the position of the existing elements in the array. Your add function merely replaces the element at the specified entry. You need to allocate a new array with an extra element and move all the following items down when you add a new entry. However, you could save yourself a lot of trouble by using one of the STL Containers[^].
Use the best guess
|
|
|
|
|
oK how about now I did fixing !
|
|
|
|
|
You are still not addressing the problem correctly. You are trying to add an element into the array, so you need to increase its size first to accommodate the new entry. Your code is just overwriting two entries with different values. Try drawing the array on paper and see what you need to do to add a new value in the middle.
Use the best guess
|
|
|
|
|
but the code work prefect and fine what I need now only make some move to the index to order the values
did you run the code
because I did increase the size of array by calling the array and increase the size using this variable
elmentnumber++;
maybe you try to say something I have no idea about it. please tell if what i'm doing not Ok and please say the reasons
|
|
|
|
|
Eshoula Aswomwe wrote: I did increase the size of array by calling the array and increase the size using this variable Incrementing a variable does not change the size of the array. You need to create a new array and copy the values into it allowing an empty cell where the new value is to be added. Then you can add that new value into the empty cell.
Use the best guess
|
|
|
|
|
hi
how to find 80 port is in use or not with c++ code or mfc
|
|
|
|
|
|
Garth J Lancaster wrote: the only way I know is to attempt to connect to the port - if that fails, the most likely reason is, is that the port is in use In use or unavailable? I ask because can't there be more than one connection to a port?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
well your use of 'unavailable' hit the nail on the head for the case I was thinking of - 'client had disconnected, but port was in timeout-wait' - ergo, not technically in use .. this may be particular to the scenario/implementation I see if happen in (a lot, unfortunately)
as to more than one connection to a port, I'd have to go back to my W Richard Stevens to check - I know what we 'see' happening in a lot of cases - eg multiple connectiins to tcp://w.x.y.z:80 may not necessarily be the case - the initial connection is accepted on that port, but then 'spun off' to be handled as a seperate conversation, leaving port 80 free
Is that what you were thinking ?
|
|
|
|
|
I'm not sure if this is relevant to you, but you can call bind[^] on the ip address and port, check if it fails and see if the error is WSAEADDRINUSE .
|
|
|
|
|
Is there a good example of using a CMFCPropertyGridCtrl?
Thanks.
|
|
|
|
|
|
I like to learning C++ with some GUI framework. After searching on Internet MFC is good native development tool for Developers but I have problem is there any value learning MFC nowadays? Because in Windows 8 application type that called Metro applications or give me some good framework to learn C++ GUI Programming
|
|
|
|
|
|
|
Yes.. Working Native means much than it sounds. You should try a little Windows API before going into MFC. If you do some Windows API (Win32), learning MFC will be much easy.
There're plenty of Online stuff for MFC, For Win32 Try the book, "Charles Petzold - Windows Programming".
Pravinda
|
|
|
|
|
"...is there any value learning MFC nowadays?"
In my opinion, the .NET environment is superior to MFC. It was written after MFC, and is much easier to use. The developers learned from their mistakes with MFC.
With MFC, problems that should take minutes to solve sometimes take days. And days.
MFC only works with C++. With .NET you can use it with C++, C#, Basic, and others.
|
|
|
|
|
Disagree !
I don't think that MFC is bad. MFC is a thin layer in front of the Windows API. So it's powerful. .NET has a long pipeline from Windows Kernel to the .NET app.
For small apps, and to develop software faster, .NET is the best. But when it comes to performance MFC is far more greater than .NET. Most of the large projects have written with Native APIs.
|
|
|
|
|
Alan Balkany wrote: With MFC, problems that should take minutes to solve sometimes take days.
How so? I always found it very simple, and if you want part of th win32 api that isnt wrapped by MFC you just call it directly. You can edit the message map simply to add WM_XXXXX commands that arent handled by the class wizzard, and can simply modify the comnstructors to pass all kinds of data round.
The only complexity would be implementing something complex, like windows hooks or some such, but that would be the same with MFR of raw win32 API.
But I agree, learn .Net and C#, it has WAY more commercial demand. (By the way, I didnt know you can use C++ with ,Net. I am a kernel guy and dont venture into user mode that much these days.)
==============================
Nothing to say.
|
|
|
|
|
The consistently incomplete documentation for MFC makes it difficult to use.
Of course an MFC expert can easily use it to solve problems. But it's not user friendly to someone who's not an expert. With .NET and intellisense, you can use .NET effectively even if you don't know it very well.
A couple examples of MFC landmines that eat up the hours and days of your development time:
1. You have a CBitmap and you want to load a .bmp file from disk. How do you do it?
(HINT: CBitmap::LoadBitmap () doesn't work. How retarded is that?)
2. You see that OnDraw () is used to update windows. Fair enough. But you try to use it on a CDialog and it doesn't f***ing work!. Part B: You try to use it on a CFrameWnd and it doesn't f***ing work, but for a DIFFERENT reason!
MFC is full of garbage like this! (And I used it back in 1997 when you couldn't just go to the Internet for a quick answer.) MFC is one of the reasons I hate Microsoft!
modified 4-Mar-13 11:20am.
|
|
|
|
|
Alan Balkany wrote: CBitmap::LoadBitmap () doesn't work. How retarded is that?
Why Windows didn't add simple .bmp, .jpg and .zip file reader/writer APIs way back with Windows 95 has always been a mystery to me.
|
|
|
|
|
I suspect it's because Microsoft sees ALL other developers as potential competition to THEIR products, so they insert conceptual roadblocks and missing or undocumented functionality to slow them down.
|
|
|
|