473,748 Members | 2,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1957
On 26 Feb 2006 12:21:50 -0800, sn***********@g mail.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**********@Ho me.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******** *************@u 72g2000cwu.goog legroups.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(da ta, 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
3679
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 ********** ColumnA ColumnB ColumnC ColumnD ColumnE
6
1649
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 a php page elsewhere which does all the computing of the gif image. I can make this work successfully by using a static call like: <img src="test12.php?a=15&b=65&c=33000" width="200" height="200"> How do I write javascript to allow the visitor...
3
1268
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 they can all see it. This works fine. My question is if there is any reason NOT to go ahead and declare ALL strings at the top? Is there a performance/memory hit in doing that? Or is it simply a matter of clean code syntax/layout?
6
3517
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 error saying to change Public to Dim. When I do, it will say that Test1 is an unused local variable.
7
2956
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 manipulate (and report on) members of the class. Interface consists of: - 5 private variables char author; char title; char code;
5
2727
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 more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently considering: Page 1: Meeting Information input with link to a document upload page (this page...
1
1292
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 standpoint to declaring all my string constants up-front as opposed to declaring them in-line? For example: public class ProjectConsts {
8
7519
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, like this: for(var i=0; i<list; i++) { var name = list; }
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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
8252
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...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
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
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3316
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
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.