473,395 Members | 1,637 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,395 software developers and data experts.

Why does this code only run like 15 letters?

#include <iostream>
#include <string>

using namespace std;


int main()
{

string setning;
string temp;

getline(cin,setning);

for (int i = 0 ; i < setning.size(); i++ ){
temp[0+i] = setning[setning.size()-1-i];
cout<<temp[i]<<' ';
}


return 0;
}

I figured it out
Nov 26 '20 #1
2 3714
dev7060
636 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. temp[0+i] = setning[setning.size()-1-i];
0 has no significance here.
Nov 26 '20 #2
AjayGohil
83 64KB
Hi,

Your code is perfectly working for any number of letter and it reverse string.
you can try below method for reverse string:

https://www.geeksforgeeks.org/getline-string-c/
Dec 16 '20 #3

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

Similar topics

1
by: ColinWard | last post by:
Hi there. I have the following code in the open event of a form. Most of it sets or checks the value of certain variables so that the form opens properly. It also sets the recordsource for the...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
2
by: Roshawn Dawson | last post by:
Hi, Does code contained in <% %> blocks cause postbacks to the server? Thanks, Roshawn
10
by: simon.hibbs | last post by:
Lets say that I have an application consisting of 3 files. A main.py file, gui.py and a data.py which handles persistent data storage. Suppose data.py defines a class 'MyDB' which reads in data...
54
by: smnoff | last post by:
Below is a section from string.c at this linkhttp://cvs.opensolaris.org/source/xref/on/usr/src/common/util/string.cthat I am trying to fully understand.I don't fully understand LINE 514; not to...
19
by: active | last post by:
The ColorPalette class has no constructor so how does one use it? I define a variable by: Dim cp as ColorPalette but don't know how assign an object to the variable. Thanks in advance
31
by: somenath | last post by:
Hi All, I was going through one of the exercise of one C tutorial . In that they have given one small code and asked about the output. #include <stdio.h> int main(void) { int x =...
7
by: Artie | last post by:
The age-old question: does size really matter? I mean code size - get your minds out of the gutter! I have a table to store customer discounts (SQL 2000). The table has up to 10 possible...
1
by: Joe Wyrwas | last post by:
My main program is a Multiple Document Interface (MDI). I create and show 2 or more child forms inside the MDI parent. If I left click on the child forms, the focus and Z-index will change...
1
by: saronyo bose | last post by:
the given code does not run in linux mint isodara. on typing cc pg206(c).c in terminal it gives bash: syntax error near unexpected token `(' wat to do ........ the above code runs in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.