|
here is what I want to do:
I want to swap the some elements of an array so I want to make a function like that:
int arr[] // this array is initialized
...
swap( int a[])
{
//swap parameters
}
swap(arr); // use the function
printarr(arr); // print the resault
The question is: how should I pass the array to the function properly, so that it changes the values of arr outside of its body too?
|
|
|
|
|
void swap (int* array) { }
|
|
|
|
|
Pass the array as a pointer.
void SwapArrayVals(int iVals[],int size){
}
and to call the function
int iData[2] = {11,22};
SwapArrayVals(iData,2);
or
int iData[2] = {11,22};
SwapArrayVals(&iData[0],2);
Also, it's not always necassary to pass the array size, but it is good practice and avoids writing outside your array.
|
|
|
|
|
Also, it could be interesting to have a look at the containers (particularly the vector) of the standard template library (STL). Basically, it will help you to maintain arrays that can be resized easily, ...
|
|
|
|
|
|
Hello all,
Am newly working with bitmap, i do have many questions regarding this.
At present am working on Visual C++, but am devolping code in C without any dialog based(No GUI), just with CLASS view and FILE view, am almost finished with the work, but the problem, now i have to open a bitmap to plot the output data on the bitmap.
Is it possible to create a Bitmap in C or should i use VC++ dialog based application only? Is there any special function?
|
|
|
|
|
Its possible to open a bitmap the same as any other "text" file. You can also use the CreateBitmap() LoadBitmap() ... functions, but I think these require that you include windows.h or at least GDI.h into your project.
I'm not sure exactly what you are rying to do, but if you do some research about DI (Device Independant) Bitmaps, these allow you to manipulate each pixel in the structure.
|
|
|
|
|
hello,
#include "windows.h"
#include "windgi.h"
#include "GDI.h"
CreateBitmap(100,100,256,16,const void*lpvbit);
am getting an error as "cannot open GDI.h"
what could be the reason?
|
|
|
|
|
Are u working on WIN32 console application?
|
|
|
|
|
ya, this is win32 console application.
|
|
|
|
|
srija wrote: Is it possible to create a Bitmap in C or should i use VC++ dialog based application only? Is there any special function?
Yes, you can create a bitmap in Plain Old C. Have a look at all the bitmap structures in MSDN.
But what are you wanting to do with the bitmap you created ?if your program only read data and create the bitmap manually, and save it back to a file, you can use paint.exe ( or any other bitmap/image viewer ) to see the resulting image.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
am having bitmap DLL, but it is based on MFC? how could i use for Visual C?
|
|
|
|
|
Hi!
I extracted alot of images from a mpg file.I want to create
an avi file from these images but I don't know how.
Can any one help me?!!!
Thank!!!
|
|
|
|
|
hi, how can i detect the last start of my windows (date and time)
is there a function or a reg-key available ?
best regards
emmi
|
|
|
|
|
GetTickCount()
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
GetTickCount() won't work for servers which have a very long uptime. You could also use QueryPerformanceCounter, which normally has a much bigger time range.
Don't try it, just do it!
|
|
|
|
|
Please can you tell me how you get the currrently selected date from this control? all I seem to be able to get is the current date.
thanks,
|
|
|
|
|
CDateTimeCtrl::GetTime(...) should return the selected date and time. Good luck!
|
|
|
|
|
cheers for your fast reply!
Andy,
|
|
|
|
|
By Scrolling half of the scroll i want the complete page scroll.
when the scrollbar is at the middle the page should display bottom.
|
|
|
|
|
Have a look on MSDN for the SCROLLINFO structure. This will enable you to set the min and max limits of the scroll bar and the thumb size. A combination of nPage and nMax will give you the desired result.
For example,
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_PAGE|SIF_RANGE|SIF_POS;
si.nPage = 5;
si.nMin = 0;
si.nMax = 9;
si.nPos = 0;
SetScrollInfo(hHscroll,SB_CTL,&si,TRUE);
nMax will set the scrollbar to be able to move 10 spaces, but nPage takes up 5 of these spaces, meaning that the scrollbar is only able to scroll the remaining 5.
In your project you should set those values according to the data you want to display. You must also process the default scrollbar messages and check the values against your display data. make use of the min() and max().
|
|
|
|
|
Thanks i had tried your solution but it is doing reverse of my requirement. My requirement is with half scroll complete page should be scrolled.If you have any other alternative please suggest me. I had tried all combination of nMax and nPage but not able to get the desired output.
|
|
|
|
|
Hi guys,
i am new to this group. i m facing a very serious problem with my project.
the details of the project are
1) we basically need to develop a client which is kind of a messenger
service something like yahoo.
2) it is based upon Jabber Technology. though there are a lot of
clients already present on this technology we want to develop a client
which is for an embedded device and not primarily for a web browser.
this is the basic reason why we want the program to be written on ANSI
C.
3) the platform on which we have to work and run this program is Visual C
4) what we have done till now is done coding for a
1) Client to Server communication and
2) Server to Client communication
3) some coding for multithreading with 1 or 2 errors
5) what is required now is to develop from this a multi threading
program which will enable us to communicate from Client to Client
through a server. this is the most primary requirement
after which XMPP protocol needs to be added
i am stuck with the multithreading part and this being my first project i really dont know how to go about it. i m really short of time and have a deadline of end of this month to submit this project. i really forward to help from you guys for my problem. in case of any further details about the project i would be more than happy to let u all know.
i am sending the multithreading program which gives few errors wn i build it. if you can solve that n make it working that would be awesome but even a new multithreading program would serve the purpose.
i really hope that i would get some help from you guys soon.
awaiting reply from you all
Regards,
S.Arunesh
|
|
|
|
|
Please post specific questions
|
|
|
|
|