473,804 Members | 3,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

constructing filename string at runtime

112 New Member
i need to open a file whose name i only know part of until runtime.

it is based on a char value.
the char represents gender and is either 'm' or ''f'

i need to load from a text file called names_m.txt or names_f.txt but i don't know until runtime.

i tried this but it didnt quite work...

Expand|Select|Wrap|Line Numbers
  1.  char fileName[18] = {"/data/names_"};
  2.   fileName[13] = gender;
  3.   fileName[14] = '.';
  4.   fileName[15] = 't';
  5.   fileName[16] = 'x';
  6.   fileName[17] = 't';
  7.   fileName[18] = '\0';
i want to use an fstream to open the file in the folder 'data' at the working directory
Oct 25 '07
10 2537
weaknessforcats
9,208 Recognized Expert Moderator Expert
[C++ Error] Civilian.cpp(36 ): E2285 Could not find a match for 'fstream::basic _fstream(string ,enum)'
Did you include <fstream>??
Oct 28 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3027
by: nfr | last post by:
I have a Singleton Model object that can be instantiated by different applications at runtime. This object activates a Channel using the config file in its constructor, which needs the name of the config file as a string. Because the object does not know the application in which it is being instantiated and because it's constructor is private, I need to know how to determine the name of the default config file (i.e.,...
10
13093
by: Brian Gruber | last post by:
Hi, I'm looking for a way to rename a whole directory of files in short order. The files in the directory have different lengths, however all of them end with _xxxx the x's represent a randomly generated number from a program that I saved from. So I need to find a way that I can quickly remove the underscore and the last 4 numbers from the filename without changing anything else. I can't set a max length to the file becuase the filename's...
3
1251
by: Crouchie1998 | last post by:
On the following page is for Symantec Antivirus updates: http://www.sarc.com/avcenter/download/pages/US-SAVCE.html Todays virus definition filename & path is: http://definitions.symantec.com/defs/20050228-024-x86.exe Notice the filename is: 20050228-024-x86.exe
11
1921
by: bgreen | last post by:
I am hoping for some assistance with formatting a large text file which consists of a series of individual records. Each record includes specific labels/field names (a sample of 1 record (one of the longest ones) is below - at end of post. What I want to do is reformat the data, so that each individual record becomes a row (some cells will have a lot of text). For example, the column variables I want are (a) HD in one column (b) BY in...
5
1788
by: Petrosky | last post by:
Hello, May I ask what built-in functions available out there in C# to search for a particular filename input from the user at runtime ? I am completely new to system thingies, so please help beginner. I appreciate any answers from you.
1
6405
by: herbert | last post by:
I am using a TraceSource object configured via app.config. In order to delete the old file before starting the new trace, I need to obtain the filename from the listener. What am I doing wrong in the following sample: Dim trc As New TraceSource("HappySource") ‘filename returns Nothing: Dim filename As String = _ trc.Listeners.Item("myTextListener").Attributes("initializeData") app.config part:
3
1136
by: David Thielen | last post by:
Hi; I have event logging working now (thank you all for the help). But we now need to add doing this to our setup program. The file on my system is: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll So my question is how do we programatically get this path and filename? 1) Where do we get the C:\WINDOWS\Microsoft.NET\Framework part from? Do we just add Microsoft.NET\Framework to the windows directory? 2) The...
1
2502
by: =?Utf-8?B?QnJpYW4=?= | last post by:
I want to convert a filename to it's equivalent unc filename. First, is there a C# call that i can use that will do it directly? If not then I will look at the Directory.FullPath() of a file and detemine it it has a VolumeSeparatorCharacter in it. If so I will then look at the DriveInfo for that volume and determine if it is a network drive. If not then I will replace the volume specifier with a unc name like \\192.168.1.2\c$\... ...
1
2122
by: James Hahn | last post by:
I have a ListView that displays files selected from various folders using a user-specified selection rule. I want to sort the files in various ways and have implemented a sorter class to do it, for instance to sort the file date as a date and not as text. But the filenames are not listed in the same sequence as in Explorer, which is some sort of 'Numeric-modified alpha' sequence. Is there a comparer that will return the correct sort...
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.