472,992 Members | 3,271 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

Inputting data with strings, and declaring variables for them

http://www.rafb.net/paste/results/fTQgRW16.html
Here's my program so far. This is what I'm trying to do:
http://contest-cemc.uwaterloo.ca/ccc...nior/phone.pdf
So far it works fine. The only problem is that I'm not sure how to
input data, s1, into the program. The second thing that I'm not sure
how to input the variable into the function.

The code:

strcpy(line, "88-SNOW-5555");

That's where the input will go. However, as you can see, I have five
inputs. I know that I should use a for loop or something for those, but
I don't know how I would incorporate it. Does anyone know? I know this
is relatively simple in java.

PS: I'm using an old borland compiler, so new methods in C++ won't
work, such as std::string, declaring a regular string, etc.

Thanks.

Feb 26 '06 #1
4 1932
On 26 Feb 2006 12:21:50 -0800, sn***********@gmail.com wrote:
http://www.rafb.net/paste/results/fTQgRW16.html
Here's my program so far. This is what I'm trying to do:
http://contest-cemc.uwaterloo.ca/ccc...nior/phone.pdf
So far it works fine. The only problem is that I'm not sure how to
input data, s1, into the program. The second thing that I'm not sure
how to input the variable into the function.

The code:

strcpy(line, "88-SNOW-5555");

That's where the input will go. However, as you can see, I have five
inputs. I know that I should use a for loop or something for those, but
I don't know how I would incorporate it. Does anyone know? I know this
is relatively simple in java.

PS: I'm using an old borland compiler, so new methods in C++ won't
work, such as std::string, declaring a regular string, etc.

Thanks.


How old? You can download the Borland command-line compiler for free
.... the same one which was used in Borland C++ Builder ver. 5. That
has a usable STL implementation, although it has some bugs
(std::getline doesn't work as advertised, for example).

Looks like "Input will be contained in the file s1.in" ... they don't
say where the file's path is located, though.

If you can't use a more up-to-date compiler which has an
implementation of the STL, you will have to open and read in the file
using either the C runtime functions or platform-specific functions.

--
Bob Hairgrove
No**********@Home.com
Feb 26 '06 #2
Tubo C++ 4.5
However I know that there is still a way to get data inside the program
and to use a variable for each line. I could use Dev C++, but I don't
have much time to learn the new methods...

Feb 26 '06 #3

<sn***********@gmail.com> schrieb im Newsbeitrag
news:11*********************@u72g2000cwu.googlegro ups.com...
Tubo C++ 4.5
However I know that there is still a way to get data inside the program
and to use a variable for each line. I could use Dev C++, but I don't
have much time to learn the new methods...


for your former ifstream sample: (ifstream fout("s1.in")) ... maybe...

char data[256];
fout.getline(data, 256);

and rename fout to fin... :P
else the mentioned c-style functions... an example you can find on

http://msdn.microsoft.com/library/de...2c_.fgetws.asp

kinda down the page. a "int n = atoi(line);" would then help to read the
number on the first line.


Feb 26 '06 #4
How about devcpp? I think it fine;

Do you want get input data from file or prompt?
if the latter one, try

while ( cin >> data )
{
.........
}

Feb 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Troll | last post by:
Hi, I need to write a script which reads some data and reports the findings. Just to give you an idea the structure is similar to the following. Data input example: HEADING 1 **********...
6
by: Eric Johnston | last post by:
I want the visitor to enter three numbers on the page and then click a button "generate image" which will I hope cause a generated gif image to be displayed alongside on the page. This involved...
3
by: darrel | last post by:
Often, I want to use a string in multiple functions on a page. I can declare and re-set the string in each function, or I can just delcare the string outside of the individual functions so that...
6
by: Mark A. Sam | last post by:
Hello, I am using Visual Web Developer 2005 Express. I want to declare a varible, using Visual Basic as the language and can't get anywhere. For example Public Test1 as String I'll get en...
7
by: fakeprogress | last post by:
For a homework assignment in my Data Structures/C++ class, I have to create the interface and implementation for a class called Book, create objects within the class, and process transactions that...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
1
by: DLN | last post by:
Hello all, I have a quick question regarding how best to use static strings in my C# code that I'm hoping someone can help me with. Is there any advantage/disadvantage from a performance...
8
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.