|
this is the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
enumerate its sub-keys
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
Hi Y'all
I am trying to insert a CString into a database table.
this is what I have but it literally puts the %s into the table remove the ' and I get an error.
CString CSWholesentence = "This is the whole sentence";
SqlString = "INSERT INTO Sentences (SENTENCE) "
"VALUES ('%s')", CSWholesentence;
database.ExecuteSQL(SqlString);
Any help greatly appreciated.
Cheers
Tryhard
|
|
|
|
|
use this instead
SqlString = "INSERT INTO Sentences (SENTENCE) VALUES('";
Sqlstring += CSWholeSentence;
SqlString += "')";
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
Thanks Guys.
Sorted.
Tryhard
|
|
|
|
|
The % replacement only works in sprintf(), CString::Format(), and their variations. It is not a feature of C++.
CString sql;
sql.Format ( _T("INSERT INTO Sentences (SENTENCE) VALUES ('%s')"), (LPCTSTR) CSWholesentence ); Note that you need to cast a CString to LPCTSTR (as I did above) when it's being used as the string for a %s substitution.
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Note that you need to cast a CString to LPCTSTR (as I did above) when it's being used as the string for a %s substitution.
Why would this be? I have used format without the LPCTSTR cast quite successfully in a number of projects.
|
|
|
|
|
You don't have to cast to LPCTSTR. CString contains only the actual pointer to the null-terminated, C-style string. If you pass CString by value, two things happen
- a space on the stack is reserved. It has a size of 4 bytes on 32-bit Windows, b/c sizeof(CString) == sizeof(TCHAR *)
- CString copy c'tor is called (it's cheap, b/c CString uses refcounting and copy-on-write)
From the Format/*printf (and all other functions expecting char *) point of view, the CString on the stack looks exactly the same as plain old char* pointer - that's why this works.
The only thing you can worry about is that in VC 8 they'll change internal representation of CString, but I'd say it's *very* unlikely - too much code is written using the assumptions above.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Because a CString is not a LPCTSTR. It may work now, but it's still wrong to leave out the cast. I'll keep doing it.
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Is there a way to set the color of a list controls column headder?
Thanks,
Rob
|
|
|
|
|
It's easy to do with custom draw. Check out NM_CUSTOMDRAW in MSDN (and be sure to read the header control variety, NM_CUSTOMDRAW works differently for different controls).
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Thanks Mike.. I'll take a look.
Rob
|
|
|
|
|
I know it is late but can someone help me with this, I know sh*t about c++ but I have to have this stupid course and have to get his assignment done can someone
|
|
|
|
|
A couple of things.
1/ No-one can help you if you don't post the question.
2/ Hopefully no-one will help you if you just post your assignment and expect a free ride. I'm sure everyone will be keen to help if you post your attempt at the problem and explain where you are stuck. If you 'know s*it' about C++, then it probably means you need to study more. Unless you're *never* going to look at C++ again, there is no point us helping you pass something you know nothing about. You're only going to find the cost of entry in terms of learning what you're supposed to know will increase the further you go without knowing your stuff.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I understand what you are, and I respect that. My problem stems from a teacher who can't teach and when he tries he confuses the sh*t out of the class. Now I'm not trying to blame it on the teacher. but right now I am so lost I'm stuck at start, and I'm not sure what to ask as my question. I know this should be a simple assignment but I am finding it hard at the moment. I think all I need is alittle help getting started in the right direction and I can take it from there!
|
|
|
|
|
If your teacher is a moron you should complain, you have a right to be taught well. Either way, you should buy some books and teach yourself instead.
That being by the by, I'd be happy to give you some pointers, but you're yet to say what the assigment is. I assume you need to write something ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Write a program that evaluates simple mathmatical expressions. the program reads one expression at a time from the user, evaluates it,and stores the result in an array. sort the expression and result in descending order of result values, and print them out. allow for a maximum of 25 expressions. ther will be three source files: main,eval and ch2int.
|
|
|
|
|
In other words a calculator ? Do you know how to do the following:
1/ read input from the user
2/ create an array
3/ parse a string ( I presume this is what ch2int will do, parse for an operator and a number )
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
main.cpp
use getline to read the expressions. each expression will consist of one operatorand two operands. the operands will be intergers. invoke the function eval to evaluate the expression and store both the expression and result into arrays. next, sort the expressions and results in descending order of results and printthem out. allow for a maximum of 25 expressions. continue this process until the user selects an option to exit.
|
|
|
|
|
And how much of this do you know how to do ? Do you know how to read in the line ? Do you know how to evaluate the result to extract the numbers ? What are you allowed to use ( can you use STL for example ).
Console app or not, Nish is right and your teacher needs shooting. There is no reason this can't all be done in one class, in one .cpp file.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I know he need shot. i don't understand any of what you said and this project is due tomorrow. I had a freind who said he would help but he had to go home to his grandfather funeral yesterday so I am needing some help.can some one help
|
|
|
|
|
I said:
And how much of this do you know how to do ? Do you know how to read in the line ? Do you know how to evaluate the result to extract the numbers ? What are you allowed to use ( can you use STL for example ).
You said:
i don't understand any of what you said and this project is due tomorrow.
Bloody hell. I am astounded that it didn't occur to you before now that you were not learning anything and that you should be. What course are you doing ? Is this the only computing component ?
You're saying this course has had no marking up until now, and if you write this program you will pass ? Is everyone in the class in the same boat ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
6 people dropped the course the other day, and we can use anything we want. as far as I can tell the teacher knows dick about c++, up until this point it was goin ok, the project seemed fairly simple, then bam this one and the teacher is so confusing. and the reaosn i took the corse was to learn c++. I knbow asp and html and web programming, so I thought I would learn a real programming language. and I get stuck with the teacher who know nothing. or at least he can't convey it!!!
|
|
|
|
|
thank guys for all the help, I really appercaite it hope fully I can figure something out in the morning. but the code from nish will help greatly. agina thank you very much. if you have any more coments or code please send them to mrthump@hotmail.com again thank you very much!!!!!
|
|
|
|
|
It must have been one hell of a short course if it had 'gone well' but you didn't know any of the things I asked you. I really recommend you buy some good books, and as for this course, that you let people in charge know that the teacher has let you down.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I've done a simple version of eval for you. You can modify it to suite your needs.
int eval(char *s)
{
int res=0;
char *a;
if((a=strchr(s,'+'))==NULL)
if((a=strchr(s,'-'))==NULL)
if((a=strchr(s,'*'))==NULL)
if((a=strchr(s,'/'))==NULL)
if(a==NULL)
return 0;
char *b=a+1;
int v2=atoi(b);
switch (a[0])
{
case '+' :
res=atoi(s)+v2;
break;
case '-':
res=atoi(s)-v2;
break;
case '*':
res=atoi(s)*v2;
break;
case '/':
res=atoi(s)/v2;
break;
}
return res;
}
Regards
Nish
Sonork ID 100.9786 voidmain
|
|
|
|