|
use the pointer:
int a[10];
for(x=0;x<10;x++)
{
*str[x] = a[x];
}
You know some birds are not meant to be caged, their feathers are just too bright.
|
|
|
|
|
#include "stdafx.h"
#include "iostream"
#include "cstring"
using namespace std;
int main()
{
int x, y;
char ppl[5][80];
for(y = 0; y < 5; y++){
gets_s(ppl[y]);
}
for(x = 0; x < y; x++){
cout << ppl[x] << "\n";
}
int a[5];
for(x = 0;x < y; x++){
*ppl[x] = a[x];
}
for(x = 0;x < y; x++){
cout << a[x] << "\n";
}
return 0;
}
compile this and see what the values for each of the strings are, it doesn't work.
and how do you output the values when the variable name is the same as the name for the string,
for example if you want to display the strings showing what their values are.
|
|
|
|
|
toprogramminguy wrote: for example if you want to display the strings showing what their values are.
toprogramminguy wrote: cout << ppl[x] << "\n";
You have made it here.
toprogramminguy wrote: int a[5];
initialize it just like cin>>a[i].....
Well,if you do really want to convert from "int (like a[x])" to "char [](like ppl[x])",what you have related before.(like "str[0]" = a1,"str[1] = a2............").(The compiler does not allow you to do like this ,but you do.)
You can try this:
sprintf(str[i],"%d",a[i]);
You know some birds are not meant to be caged, their feathers are just too bright.
modified on Monday, September 8, 2008 10:25 PM
|
|
|
|
|
Thanks ill try that but can you set each of the strings be a variable name and then set a value, as opposed to setting a value to a variable name then setting the string equal to that variable name, if you can understand me and my terrible way of explaining things.
I'm only learning c++ by myself so i haven't got a clue really
thanks again
|
|
|
|
|
#include <string>
using namespace std;
string str1,str2;
str1 = "this is my first string.";
str2 = "this is my second string."
cout<<str1<<endl;
cout<<str2<<endl;
String is a class in boost c++ library,and it has many member functions
to deal with string,you can do a search about it,or find a book contains
chapter string.
You know some birds are not meant to be caged, their feathers are just too bright.
|
|
|
|
|
Cannot figure out i am doing wrong.
Program works fine, List with a check box. Initially ViewJob() is call in the On_InitDialog(). But on refreshing the data list after CheckBox check, get error saying "cannot open any more table"
//control notification
ON_NOTIFY(LVN_ITEMCHANGED, IDC_JOB_LIST, OnItemchangedLinksList)
//
void CICT_JOBS_ADMINDlg::OnItemchangedLinksList(NMHDR* pNMHDR, LRESULT* pResult)
{
CDaoDatabase onclickdb;
CDaoRecordset OnrecSet(&onclickdb);
int nItem = m_ViewJobs.GetItemCount();
CString strSQL;
onclickdb.Open("ICTNAS.mdb");
for(nItem =0 ; nItem < m_ViewJobs.GetItemCount();nItem++) {
BOOL bCheck = m_ViewJobs.GetCheck(nItem);
if( bCheck == 1)
{
CString sub = m_ViewJobs.GetItemText(nItem, 1);
OnrecSet.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Task WHERE Subject = '"+sub+"'",NULL);
OnrecSet.Edit();
OnrecSet.SetFieldValue("Task","TRUE");
OnrecSet.Update();
UpdateData(TRUE);
OnrecSet.Close();
onclickdb.Close();
ViewJobs(); *****Error With This line*****Refresh the Listbox***
}
}
*pResult = 0;
}
void CICT_JOBS_ADMINDlg::ViewJobs()
{
COleVariant var,varValue;
var.ChangeType(VT_BSTR, NULL);
CDaoDatabase vewdb;
CDaoRecordset rvewSet(&vewdb);
ListView_SetExtendedListViewStyle
(m_ViewJobs.m_hWnd, LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES);
CString subJect,date;
vewdb.Open("ICTNAS.mdb"); // Open Clients.MDB
rvewSet.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Task WHERE Task=NO ",NULL);
while(!rvewSet.IsEOF()) // Do until EOF
{
int i = 0;
rvewSet.GetFieldValue("Subject",var);
subJect = (LPCSTR)var.pbstrVal;
m_ViewJobs.InsertItem(0,"",0);
m_ViewJobs.SetItemText(0,1,subJect);
rvewSet.GetFieldValue( "Start Date", varValue );
date = COleDateTime(varValue).Format(_T("%d/%m/%y"));
m_ViewJobs.SetItemText(0,2,date);
i=i++;
rvewSet.MoveNext();
}
rvewSet.Close();
vewdb.Close();
}
any help would be nice.
Gpat
|
|
|
|
|
It could be because of the limitation of the Access Driver. BTW,What is the upper limit of the loop that is getting executed?
Regards,
Rane
|
|
|
|
|
But the proram open database once,reads data, and then closes. and when user check the checkbox, program opens database and makes changes and closes. it works fine upto here, but when refreshing the listbox ( by calling the original function ) this where the error occurs.
Gpat
|
|
|
|
|
Why are you using DAO?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi guys. I'm using a third party MFC CListCtrl inheriting class, that comes with its own CHeaderCtrl inheriting class - http://www.codeproject.com/KB/list/creportctrl.aspx[^] . It works well, but the function that updates the header of the CListCtrl to display the arrow that indicates the order of a given sort (ascending or descending) has an undesirable side effect; when called, it makes the sorted column's header appear completely flat, rather than 3D, and when the cursor rolls over the column it doesn't become highlighted. This only seems to be a problem in Windows XP.
Here's the relevant code:
void CReportCtrl::CReportHeaderCtrl::UpdateSortArrow()
{
HD_ITEM hditem;
hditem.mask = HDI_FORMAT;
VERIFY(GetItem(m_iSortColumn, &hditem));
hditem.fmt |= HDF_OWNERDRAW;
VERIFY(SetItem(m_iSortColumn, &hditem));
Invalidate();
}
If one of you could suggest a way of avoiding this, and having the arrow appear without changing the appearance of the header, that would certainly be appreciated,
Regards,
Sternocera
|
|
|
|
|
Hello
I am working on a new virtual world and I need help on writing the source code. I do not want to use a game engine like Multiverse or anything like that. I have used them for past project but now I feel that I move up a stage in virtual world development.
I am planning to use Bloodshed for the compiler. I would be grateful if someone could help me on this project.
Thank you.
Andrew McIntyre
|
|
|
|
|
That sounds like a pretty big feat, and doesn't have a simple answer. For more specific queries you might want to ask in the Graphics forum[^].
For 3D development work, there are obviously a number of platforms that you can work upon, such as DirectX or OpenGL; I'd recommend that you start doing some research on 3D programming and deciding what platform you want to write your virtual world upon - I'm sure CP has a lot of useful articles regarding 3D programming. Then you can look at coding using these platforms in more detail. Google[^] is always good for that.
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
I have decided to use DirectX for this world.
|
|
|
|
|
Then I think the first thing to do if you want to develop your own engine is to buy a good book on DirectX and learn from that. You can't learn something valuable just by asking questions on a forum (or it will take you ages to have a decent understanding of it). Once you are quite familiar with DirectX, you will be able to move to more complex stuff.
|
|
|
|
|
You can use of OpenGl or Directx of course you can use of Opengl on all platforms.Good book about DirectX is helpful (programming Dicrect3d and Devices and Surfaces and also you must be know some info about Vertices,Points, programming sound,programming animation...etc.
|
|
|
|
|
I am mainly concentrating on DirextX. I am hoping to have sound in the world, so maybe when the world loaded you will hear loading music. Animation will play a big part in the world or the avatar will not be useful for anything.
|
|
|
|
|
Dear sir
i got the error
'/RTC1' and '/clr' command-line options are incompatible
because i used a dll file created in c# ( managed ) and my code is a mixed between managed and unmanaged
this dll file contain a namespace LORD
when i call this namespace by using the command
using namespace LORD
i got the error
'/RTC1' and '/clr' command-line options are incompatible
how can i trun the run time check off or how can i solve this problem
i will be vert thanfull for any reply or help or any tips that may help
with best wishes
modified on Sunday, September 7, 2008 7:47 AM
|
|
|
|
|
This is due to incompatible Settings. Try out the follwing:
1)Open the project Properties
2) Set the "BasicRuntimeChecks" option as FALSE.
(c/c++ -> Code Generation ->BasicRuntimeChecks = FALSE)
3) Rebuild and test it once again.
Hope this may help...
Regards,
Rane
|
|
|
|
|
Hi, in C++ I can implement callback functions:
void (MYFUNC) (int);
void func1 (int n)
{
//some code
}
void main()
{
MYFUNC * f = &func1;
(*f)(2); //calls func1
(*f)(3);
}
This is simple enougth. But my question is another. How to implement the same thing on objects member function. i.e. - save object pointer and pointer to the function, then call this function for this object. I know that this is another calling conversion. I could pass object as first parameter, but on some arhitectures it's passed to stack in others to ECX register. I need more accurate code.
Does anyone know how to do this?
Thanks
|
|
|
|
|
|
|
hi every one
how i can change CLSID in mfc activex project?
is it possible?
|
|
|
|
|
Use GUIDGEN.exe and copy the ID that got generated into appropriate place in the .idl file. Rebuild the project once again.
Regards,
Rane
|
|
|
|
|
Hi,
I've just (nearly) completed a module that provides usefull services to my Suite of programs. It spends most of it's time waiting on a pipe for a message. It is written as a Dlg based MFC App, but it never gets as far as showing the Dialog. All relevant Code is called in CWinApp::InitApp() It has no output, All output is sent back to the Client over a Pipe, only if things realy screw up, does it write output to an Event file. What do I do to have this app started as part of the system startup, and what do I do to start this Not as a Running App, but as something that sits in the sys tray. My Target Environment is Windows XP. Vista Restrictions are not an issue here.
Regards,
Bram van Kampen
|
|
|
|
|
Bram van Kampen wrote: What do I do to have this app started as part of the system startup
You can place a shortcut in the Start Menu, in Programs->Startup.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|