[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to assign a path of a file to a const WCHAR  * or const FSSpec *?

Posted on 2000-04-01
4
Medium Priority
?
531 Views
Last Modified: 2012-06-21
I'm trying to assign the path of a file to either:

const WCHAR *ptr;
or
const FSSpec *optr;

(These are contained in a structure called FILEIN in the header file.)


This is my path I want one of these to point to:
c:\\myfile.txt"

Here is the method that I'm assigning the values in:

int WINAPI Openfile(const FILEIN *fin)


In this method how do I set either ptr or optr to point to the file path?

Thanks :)

0
Comment
Question by:nicolac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 2677010
It would be helpful if we knew what FILEIN was.  You say it is a structure, but we could really use its definition.  but the basic idea should be that you declare an instance of the structure and fill in its data members, in particular the path.  Then you pass a pointer to this structure instance.   For example, if the structure has a member called "path" that is a char * pointer to the file path, you would do

FILEIN FilDat;

FilDat.path = "C:\\MYFILE.DAT";

OpenFile(&FilDat);

Let me know if you have any questions.  (More info from you woudl help though...)
0
 

Author Comment

by:nicolac
ID: 2677483
Here is the structure FILEIN:

STRUCTUREBEGIN(FILEIN) /*File Input info*/
#if !defined(MAC)
      const WCHAR *ptr;      // full path of file to open
#else
      const FSSpec *optr;      // file to open
#endif
.....
STRUCTUREEND

In the method

int WINAPI Openfile(const FILEIN *fin)

I want to set the value of either
const WCHAR *ptr;
or
const FSSpec *optr;

Does this explain it better?

You said: For example, if the structure has a member called "path" that is a char * pointer to the file path...
This is it:  const WCHAR *ptr;

0
 
LVL 22

Expert Comment

by:nietod
ID: 2677528
Then you would do

FILEIN FilDat;

FilDat.ptr = "C:\\MYFILE.DAT";
OpenFile(&FilDat);

except the string in this case is a wide-character string, so you need to isnure you assigning the pointer to a wide character string. If you are using a string literal (like above) you do that by placing a "L" (long) before the string like

FilDat.ptr = L"C:\\MYFILE.DAT";

if you are initializing the pointer to point to a buffer that stores the string (rather than a strign literal), then you need to make sure the buffer is declared a storign wide characters.

Does that help?
0
 

Author Comment

by:nicolac
ID: 2677709
Great thats it, thanks :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question