473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Reading Strings

compman9902
105 100+
Thank you for reading this discussion, your help is greatly appreciated.
My problem is that I am trying to make a program that reads a string and one by one picks the letter and gives it the preassigned integer.
Everything is going great, the only problem is that I cannot seem to get my program to read the string peice by peice. Here is the code:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <sstream>
  6. #include <string.h>
  7. using namespace std;
  8. int main()
  9. {
  10. string input;
  11. int position;
  12. char letter;
  13. cin  >> input;
  14. original[position] = letter;
  15. ...
The only part of the code that is giving me trouble is the "original[position] = letter;" part.
Again, thank you for your time and effort.

--Parker Woods
Mar 21 '07 #1
6 1321
DeMan
1,806 1GB
I'm afraid you may have to post some more code, it is not clear where letter, position or original are set/initialised, and since you think the problem may be at a line that involves all three, it would be nice to be able to trace what they all should be.
Mar 21 '07 #2
compman9902
105 100+
I'm afraid you may have to post some more code, it is not clear where letter, position or original are set/initialised, and since you think the problem may be at a line that involves all three, it would be nice to be able to trace what they all should be.
They are all variable. But for example's sake, I will do this:
Expand|Select|Wrap|Line Numbers
  1. original[position] = letter;
  2. original = "aAbBcC";
  3. position = 2;
The only problem is that I cannot get "letter" to equal "b".
I just need help on how to do that

--Parker Woods
Mar 21 '07 #3
DeMan
1,806 1GB
try:
Expand|Select|Wrap|Line Numbers
  1. letter = original[position];
  2.  
Mar 21 '07 #4
Roonie
99
(and put it after
Expand|Select|Wrap|Line Numbers
  1. original = "aAbBcC";
  2. position = 2;
)
Mar 21 '07 #5
compman9902
105 100+
try:
Expand|Select|Wrap|Line Numbers
  1. letter = original[position];
  2.  
Thank you very much, it worked perfectly.
Such a simple solution to a seemingly complex problem
Thanks again
Mar 21 '07 #6
DeMan
1,806 1GB
No worries, any time!!
Mar 21 '07 #7

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

Similar topics

1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
24
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
0
by: rth | last post by:
I need to read the Security Event Log and then show the EVENTLOGRECORD as a String. Reading records works fine but when I format the string that I'm going to show the FormatMessage function...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
4
by: Gaijinco | last post by:
I had a file named nap.in which looks like this: 4 10:00 12:00 Lectures 12:00 13:00 Lunch, like always. 13:00 15:00 Boring lectures... 15:30 17:45 Reading 4 10:00 12:00 Lectures 12:00 13:00...
18
by: John | last post by:
Hi, I'm a beginner is using C# and .net. I have big legacy files that stores various values (ints, bytes, strings) and want to read them into a C# programme so that I can store them in a...
9
by: dgleeson3 | last post by:
Hello All I have a txt file of strings of different lengths. I dont know how many strings are in the file. I have no problem reading the file and sending to the console (as below). To...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
2
by: otorojava | last post by:
The script works but I'm having a problem reading double and boolean import java.io.*; import java.util.StringTokenizer; import javax.swing.JOptionPane; public class FileAddress {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.