Luffy Posted October 6, 2013 Share Posted October 6, 2013 (edited) I WILL PAY YOU 1m in OSRS money if you can help me with this. I would offer more, but I feel like for a professional programmer, this would be easy. Could someone tell me how to code this: I'm reading this line from a file: int variableName = 10; (this is stored in a String called data temporarily) I need to push the variable name onto my stack, and then the actual value of the variable onto another stack. HOW DO I CODE THIS? PLEASE HELP AND SAVE MY WHOLE LIFE. Also note: the variableName can be any length up to 20 chars, and I think the value can be anything. My attempt: Alright, so I saw the split method in the String class. What I was thinking of doing was: String[] sides = data.split("="); Edited October 6, 2013 by Luffy Link to comment Share on other sites More sharing options...
Guest Shakur Posted October 6, 2013 Share Posted October 6, 2013 Anon is reading this thread, may all your powers be resolved. Link to comment Share on other sites More sharing options...
Anon Posted October 6, 2013 Share Posted October 6, 2013 You don't need to necessarily write all that to the file just write the int value and then read it and assign it to an int. Pushing onto the stack in java i think is weird and stuff. Link to comment Share on other sites More sharing options...
Luffy Posted October 6, 2013 Author Share Posted October 6, 2013 No, it's part of my assignment. The file the program is reading is a program in C. Whenever the C program makes a variable, like int varName = 10;, I have to push the name of the variable into my stack, and the value of it into the other stack. And then, eventually, it'll tell me to print all the local variables, at which point I pop the variables and their values, and print them, or it can tell me to only pop one of the specified variables. Link to comment Share on other sites More sharing options...
Anon Posted October 6, 2013 Share Posted October 6, 2013 Oh crap i just realized this was under Application Dev. Sorry bout that Link to comment Share on other sites More sharing options...
Luffy Posted October 6, 2013 Author Share Posted October 6, 2013 So does that mean you can't help me? Aww Link to comment Share on other sites More sharing options...
Violent Posted October 6, 2013 Share Posted October 6, 2013 i'd help if i knew what i was talking about Link to comment Share on other sites More sharing options...
Toxicity Posted October 6, 2013 Share Posted October 6, 2013 ^ what a useless comment Link to comment Share on other sites More sharing options...
emu Posted October 6, 2013 Share Posted October 6, 2013 (edited) So your saying that int variableName = 10; is a string that you need to retrieve the value 10 from? I've only done a little c++, but I would split the string from the 'space' and the ';' to get the value 10, then parse it to an int. I had code doing something similar for an assignment (again c++ not c) but cant find it on my hd sorry. Edited October 6, 2013 by emu Link to comment Share on other sites More sharing options...