I don't really get what you are asking, do you mean you have the test.txt file on the desktop and the code for opening it is for a user, but you want to open the file again on another user?
for example: /home/ws14 is my user. but if I transfer the c++ file to another user it cant open the path /home/ws14. because it is not the same user. how do I make the path general? with a folder. that you dont need to change the code for the user and another user. thanks!
on a u*x system, / is your root. /home/ws14 is a private home directory, so you probably need to place the text file into some public directory instead. if you don't care on whose desktop the file is, you can try accessing ~/Desktop/text.txt, but it will be up to the other users to ensure they have such file on their respective desktop.
for example: /home/ws14 is my user. but if I transfer the c++ file to another user it cant open the path /home/ws14. because it is not the same user. how do I make the path general? with a folder. that you dont need to change the code for the user and another user. thanks!
You could get the username by using popen in combination with whoami :
I've not done any programming for unix/linux (yet!), so I don't know anything about the various API's/libraries involved, but I'm sure there will be some equivalent functionality somewhere in the *nix codebase to do this. If anybody knows what it is, then that will be the most likely solution to this thread!
Hope this is in some way useful.
Cheers for now,
Jas.
on a u*x system, / is your root. /home/ws14 is a private home directory, so you probably need to place the text file into some public directory instead. if you don't care on whose desktop the file is, you can try accessing ~/Desktop/text.txt, but it will be up to the other users to ensure they have such file on their respective desktop.
Yes this is a good help quartzie. But is there a posible code to auto detect the user? or a code that can create a folder on public and inside the folder is the textfile that you can read/write?.
because if you just put it in Desktop it has a posibility to delete that file even if it is hiden file .text.txt. and then the C++ code for the read is being crashed.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.