|
From: <fer...@te...> - 2003-06-11 22:11:46
|
Hi! In this: sprintf(sql_lt,"select data,titulo,categoria,anotacao,ROWID from anot where %s like '%s';",prcampo,prprocurar); I get something like this: select data,titulo,categoria,anotacao,ROWID from anot where titulo like 'mytitle'; But when I try place a % there is an error, or the value appears wrong or I get a NULL string, by example, I need this output select data,titulo,categoria,anotacao,ROWID from anot where titulo like '%mytitle%'; I try to place one %, two %(like tell in libc reference), \% and nothing gives what I want. Can you show me how to do this? Thanks. |
|
From: Luis C. <ad...@co...> - 2003-06-11 22:40:21
|
I really don't know why you would want to look for a special symbol at all. The [like] command will match without the % being there. Unfortunately, the [like] also may be using a type of pattern matching symbols. What type of database are you running may be the right question. Is there any docs on pattern matching with [like] for your database manager ?? ----- Original Message ----- From: "Fernando Conceição" <fer...@te...> To: <dev...@li...> Sent: Wednesday, June 11, 2003 4:04 PM Subject: [Dev-C++] Help with sprintf > Hi! In this: > sprintf(sql_lt,"select data,titulo,categoria,anotacao,ROWID from anot > where %s like '%s';",prcampo,prprocurar); > I get something like this: > select data,titulo,categoria,anotacao,ROWID from anot where titulo like > 'mytitle'; > But when I try place a % there is an error, or the value appears wrong > or I get a NULL string, by example, I need this output > select data,titulo,categoria,anotacao,ROWID from anot where titulo like > '%mytitle%'; > I try to place one %, two %(like tell in libc reference), \% and nothing > gives what I want. > Can you show me how to do this? > > Thanks. > > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: eBay > Great deals on office technology -- on eBay now! Click here: > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > |
|
From: <a_g...@ya...> - 2003-06-11 23:03:30
|
This one works!!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char sql_lt[128] = {'\0'};
char *prcampo = "hello";
char *prprocurar = "world";
sprintf(sql_lt,"select data,titulo,categoria,anotacao, \
ROWID from anot where %s like \'%%%s%%\';",prcampo,prprocurar);
puts(sql_lt);
return 0;
}/*main*/
Fernando_Conceição <fer...@te...> wrote:
Hi! In this:
sprintf(sql_lt,"select data,titulo,categoria,anotacao,ROWID from anot
where %s like '%s';",prcampo,prprocurar);
I get something like this:
select data,titulo,categoria,anotacao,ROWID from anot where titulo like
'mytitle';
But when I try place a % there is an error, or the value appears wrong
or I get a NULL string, by example, I need this output
select data,titulo,categoria,anotacao,ROWID from anot where titulo like
'%mytitle%';
I try to place one %, two %(like tell in libc reference), \% and nothing
gives what I want.
Can you show me how to do this?
Thanks.
-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
Thanx and Regards
Avik Ghose
Catch all the cricket action. Download Yahoo! Score tracker |
|
From: <fer...@te...> - 2003-06-12 04:38:13
|
Thanks, this works fine!
My problem really was not with sprintf at last, i was using g_print()
from gtk to show this(is a graphical application, only to debug) and
with it I get an error.
Using your sample(changing puts by g_print) too gives an error but now i
do with puts and appear exactly I want.
Avik Ghose escreveu:
> This one works!!
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> int main()
> {
> char sql_lt[128] = {'\0'};
> char *prcampo = "hello";
> char *prprocurar = "world";
> sprintf(sql_lt,"select data,titulo,categoria,anotacao, \
> ROWID from anot where %s like \'%%%s%%\';",prcampo,prprocurar);
> puts(sql_lt);
> return 0;
> }/*main*/
>
>
> Fernando_Conceição <fer...@te...> wrote:
>
> Hi! In this:
> sprintf(sql_lt,"select data,titulo,categoria,anotacao,ROWID from anot
> where %s like '%s';",prcampo,prprocurar);
> I get something like this:
> select data,titulo,categoria,anotacao,ROWID from anot where titulo
> like
> 'mytitle';
> But when I try place a % there is an error, or the value appears
> wrong
> or I get a NULL string, by example, I need this output
> select data,titulo,categoria,anotacao,ROWID from anot where titulo
> like
> '%mytitle%';
> I try to place one %, two %(like tell in libc reference), \% and
> nothing
> gives what I want.
> Can you show me how to do this?
>
> Thanks.
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: eBay
> Great deals on office technology -- on eBay now! Click here:
> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
> Thanx and Regards
> Avik Ghose
>
> Catch all the cricket action. Download Yahoo! Score tracker
> <http://in.sports.yahoo.com/cricket/tracker.html>
>
|
|
From: <a_g...@ya...> - 2003-06-12 13:18:28
|
Looks like a bug with g_print when too many formtters are used :-). Thanks for telling that, I will be carefull in the future.
Fernando_Conceição <fer...@te...> wrote:Thanks, this works fine!
My problem really was not with sprintf at last, i was using g_print()
from gtk to show this(is a graphical application, only to debug) and
with it I get an error.
Using your sample(changing puts by g_print) too gives an error but now i
do with puts and appear exactly I want.
Avik Ghose escreveu:
> This one works!!
>
> #include
> #include
> #include
> int main()
> {
> char sql_lt[128] = {'\0'};
> char *prcampo = "hello";
> char *prprocurar = "world";
> sprintf(sql_lt,"select data,titulo,categoria,anotacao, \
> ROWID from anot where %s like \'%%%s%%\';",prcampo,prprocurar);
> puts(sql_lt);
> return 0;
> }/*main*/
>
>
> Fernando_Conceição wrote:
>
> Hi! In this:
> sprintf(sql_lt,"select data,titulo,categoria,anotacao,ROWID from anot
> where %s like '%s';",prcampo,prprocurar);
> I get something like this:
> select data,titulo,categoria,anotacao,ROWID from anot where titulo
> like
> 'mytitle';
> But when I try place a % there is an error, or the value appears
> wrong
> or I get a NULL string, by example, I need this output
> select data,titulo,categoria,anotacao,ROWID from anot where titulo
> like
> '%mytitle%';
> I try to place one %, two %(like tell in libc reference), \% and
> nothing
> gives what I want.
> Can you show me how to do this?
>
> Thanks.
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: eBay
> Great deals on office technology -- on eBay now! Click here:
> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
> Thanx and Regards
> Avik Ghose
>
> Catch all the cricket action. Download Yahoo! Score tracker
>
>
Thanx and Regards
Avik Ghose
Catch all the cricket action. Download Yahoo! Score tracker |