| View previous topic :: View next topic |
| Author |
Message |
Pihas
Joined: 25 Oct 2008 Posts: 60 Location: Lithuania
|
Posted: Wed Jul 01, 2009 2:11 am Post subject: [Solved] folder name as variable |
|
|
How corectly to do it ? I can't find out :/
(C programing language + oslib)
----------------------------------------------
int folder_name_variable;
folder_name_variable = Brew;
Picture = oslLoadImageFile("Root/..folder_name_variable../test.png", OSL_IN_RAM, OSL_PF_5551); _________________
Cooming Soon
Last edited by Pihas on Wed Jul 01, 2009 5:13 am; edited 2 times in total |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Wed Jul 01, 2009 2:29 am Post subject: |
|
|
Better learn to program C first... _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
Producted
Joined: 04 Jun 2009 Posts: 56
|
|
| Back to top |
|
 |
Pihas
Joined: 25 Oct 2008 Posts: 60 Location: Lithuania
|
Posted: Wed Jul 01, 2009 3:10 am Post subject: |
|
|
I am asking just to write one simple situacion and you bring me link to wiki and advise to learn C.... Is it so hard?... _________________
Cooming Soon |
|
| Back to top |
|
 |
coolkehon
Joined: 20 Oct 2008 Posts: 355
|
Posted: Wed Jul 01, 2009 3:15 am Post subject: |
|
|
theres alot you need to learn but here
create a temporary collection or chars and use sprintf or snprintf look them up a good place is cpprefrence.com and cprogramming.com |
|
| Back to top |
|
 |
svxs
Joined: 19 Jun 2009 Posts: 15
|
Posted: Wed Jul 01, 2009 4:03 am Post subject: |
|
|
| Quote: | int folder_name_variable;
folder_name_variable = Brew;
Picture = oslLoadImageFile("Root/..folder_name_variable../test.png", OSL_IN_RAM, OSL_PF_5551); |
It's tough to see what you're trying to do. Is folder_name_variable really an integer, or should it be a string? What is the type of Brew?
The most confusing thing is whether or not you want the _name_ of the variable as a token in your string, or if you want the _contents_ of the variable in the string. In the former case, you're not going to be able to pull that off without some mightily obscure extension to your compiler unless you want to keep track of it somewhere else by yourself.
But even then, it doesn't make sense. How would you address the name of the variable? You'd logically need to know its name in advance anyway. I imagine the obscurity of it is a mitigating factor in ISO 9899's decision to not support that. :)
In the ladder case where you'd want the contents of the variable to show up in your string, you could use sprintf() to write a formatted string to a buffer and use that. |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Wed Jul 01, 2009 5:05 am Post subject: |
|
|
I think he's trying to do something like this:
| Code: | char* strfolder_path = "Brew";
/* No more than 80 characters in path */
char* strpath[80] = "Root/";
strcat(strpath, strfolder_path);
strcat(strpath, "/test.png");
Picture = oslLoadImageFile(strpath, OSL_IN_RAM, OSL_PF_5551); |
Maybe... :/ _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
Last edited by m0skit0 on Wed Jul 01, 2009 5:09 am; edited 1 time in total |
|
| Back to top |
|
 |
Pihas
Joined: 25 Oct 2008 Posts: 60 Location: Lithuania
|
Posted: Wed Jul 01, 2009 5:09 am Post subject: |
|
|
Thx m0skit0 that was exactly what i wanted to do . You saved my life time :-)
svxs, i am learnign programing by self and i don't know a lot things, even basics. I know other languages like PHP, LUA but have diferent sintax then C :/ _________________
Cooming Soon |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Jul 01, 2009 7:09 am Post subject: |
|
|
| You're making things harder on yourself by trying to learn both the PSP and C at the same time. We recommend people learn C, THEN move on to programming the PSP. It's easier, and means less basic questions here. We don't teach C, so if your question is C related, you're more likely to get razzed than to get an answer. |
|
| Back to top |
|
 |
|