Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / String problem

Author
Message
wh1sp3r
21
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Czech republic
Posted: 27th Jan 2008 21:36 Edited at: 27th Jan 2008 22:46
hello,

I have problem with that code



While is still looping

When it found "[SOURCES]" ..strcmp(file_data,"[SOURCES]") this function return 0. I dont know WHY ! When the condition is FALSE, It dont want to jump away from while loop

if you uncomment "if(strcmp(file_data,"[SOURCES]")==0) dbPrint("JOOOOO");
" Its show JOOOO, when "SOURCES" found.


PS: Real programmers aren't afraid of math!.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 28th Jan 2008 15:48
Try to declare (and feed with the initial value)



before the while loop...
wh1sp3r
21
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Czech republic
Posted: 28th Jan 2008 16:28 Edited at: 28th Jan 2008 16:31
Morcilla: It doesnt work


PS: Real programmers aren't afraid of math!.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 28th Jan 2008 16:41 Edited at: 28th Jan 2008 16:45
Sure, that was because the variables defined inside an 'if', or inside any loop, are local variables, and can only be 'seen' inside that loop or if.

I see you have defined

at the beginning of the code. Now this variable is a global one, and can be used anywhere.

But later you wrote:



That 'char* file_data' defines a new variable, with the same name than the global one. Bad practice in any case.
I guess you wanted to say:



to keep on using the global variable. Otherwise, inside the loop, the local one is the one used, and the 'while' is probably checking the global one.

One C/C++ basics is that when using arrays, the name of the array holds the pointer to the array, that is, in this case 'file_data' is already a pointer of type 'char*'.

[Edit: Lol, you shouldn't edit your posts that way, now where stands what I said, lol]
wh1sp3r
21
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Czech republic
Posted: 28th Jan 2008 16:56
Morcilla: Hehe Thank you for explanation. I'll try


PS: Real programmers aren't afraid of math!.
wh1sp3r
21
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Czech republic
Posted: 28th Jan 2008 17:02 Edited at: 28th Jan 2008 17:20
Still problem:



ERROR:


Problem is Here "file_data = dbReadString( 1 );"



EDIT:

This works:



PS: Real programmers aren't afraid of math!.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 29th Jan 2008 10:21
Well, I haven't used dbReadString before, so I really don't know if it reads a single char or a whole string uh.
I guess you're going to find out before I do.
What does return

then?
I guess the aim is to read a file until the reading reaches the "[SOURCES]" string...
At least now you have the variables properly declared.

Login to post a reply

Server time is: 2024-11-20 01:22:20
Your offset time is: 2024-11-20 01:22:20