Connecting Tech Pros Worldwide Forums | Help | Site Map

2 Simple questions

nooria
Guest
 
Posts: n/a
#1: Jul 22 '05
1. How do you find out the length of the following GStrings?

GString FilePath [] = {"UnSigned\\EF.DG1", "UnSigned\\EF.DG2",
"UnSigned\\EF.DG3", "UnSigned\\EF.DG4", "UnSigned\\EF.DG5"};

I know the length is 5 but I like to find out dynamically. For example,
I want to use that GString in a for loop.

for (int i =0; i<(I want to put the length of the file Path here); i++){

}


2. How can you search a directory to see how many files with what kind
of extensions are in that directory?

For example, I have the following directory c:\myapp; I don't know how
many files are there or with what extensions.

Thanks in advance

JKop
Guest
 
Posts: n/a
#2: Jul 22 '05

re: 2 Simple questions


nooria posted:
[color=blue]
> 1. How do you find out the length of the following GStrings?
>
> GString FilePath [] = {"UnSigned\\EF.DG1", "UnSigned\\EF.DG2",
> "UnSigned\\EF.DG3", "UnSigned\\EF.DG4", "UnSigned\\EF.DG5"};[/color]
[color=blue]
>
> I know the length is 5 but I like to find out dynamically. For example,
> I want to use that GString in a for loop.
>
> for (int i =0; i<(I want to put the length of the file Path here); i++){
>
> }
>
>
> 2. How can you search a directory to see how many files with what kind
> of extensions are in that directory?
>
> For example, I have the following directory c:\myapp; I don't know how
> many files are there or with what extensions.[/color]

This is platfrom specific. If you're running Windows, then use the
functions:

FindFirstFileEx
FindNextFileEx
FindClose


-JKop
John Harrison
Guest
 
Posts: n/a
#3: Jul 22 '05

re: 2 Simple questions



"nooria" <nooria@saic.com> wrote in message news:40d91f75@cpns1.saic.com...[color=blue]
> 1. How do you find out the length of the following GStrings?
>
> GString FilePath [] = {"UnSigned\\EF.DG1", "UnSigned\\EF.DG2",
> "UnSigned\\EF.DG3", "UnSigned\\EF.DG4", "UnSigned\\EF.DG5"};
>
> I know the length is 5 but I like to find out dynamically. For example,
> I want to use that GString in a for loop.
>
> for (int i =0; i<(I want to put the length of the file Path here); i++){
>
> }
>[/color]

You can find out the size of any array like this

sizeof FilePath/sizeof FilePath[0]

john


Closed Thread


Similar C / C++ bytes