My trouble causing lines are maked within the code. -
#include<iostream>
-
#include<string>
-
using namespace std;
-
-
void main()
-
{
-
string* head;
-
string* tail;
-
head = new string;
-
tail = new string;
-
-
string reString;
-
-
cout<<"Enter a some content you want reversed: ";
-
getline(cin,reString);
-
-
-
head* = reString[index];//problem here
-
tail* = reString[index2];// and here
-
-
Though I don't show it index and index2 have been initialized. The lines that I've marked are giving me the error C2059: syntax error : '='. I have no clue what that means. I've tried removing the *, but that only gives me a different error. It proably dosen't help that Im not good with pointers.
Helps appreciated, thanks.
3 1325 Ganon11 3,652
Recognized Expert Specialist
Use head = &reString[index], or (*head) = reString[index]. Not sure which of those will work, but one of them sure will.
My trouble causing lines are maked within the code. -
#include<iostream>
-
#include<string>
-
using namespace std;
-
-
void main()
-
{
-
string* head;
-
string* tail;
-
head = new string;
-
tail = new string;
-
-
string reString;
-
-
cout<<"Enter a some content you want reversed: ";
-
getline(cin,reString);
-
-
-
head* = reString[index];//problem here
-
tail* = reString[index2];// and here
-
-
Though I don't show it index and index2 have been initialized. The lines that I've marked are giving me the error C2059: syntax error : '='. I have no clue what that means. I've tried removing the *, but that only gives me a different error. It proably dosen't help that Im not good with pointers.
Helps appreciated, thanks.
Remember pointers are supposed to contain address values. I'm not really sure what your program is supposed to be doing, but you should be assigning head and tail address values of strings.
Thanks the (*head) one worked, I belive my star was in the wrong place. Thanks, I miss little things like that alot.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: agent349 |
last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1
== array2)). However, I've been trying to compare two arrays using
pointers with no success. Basically, I want to take three sets of
character strings from the user. Then I want to run through each
element and compare the two strings. If they match I print they
match... I'm having a bit of trouble with the actual loop through each
array using the pointers and comparing...
|
by: Stephane Vollet |
last post by:
Can someone tell me what's wrong with my code here?
When compiling, it says :
error C2143: syntax error : missing ';' before '*'
error C2501: 'Tcase' : missing storage-class or type specifiers
error C2501: 'm_cases' : missing storage-class or type specifiers
the compiler points out the problem on this:
Tcase* m_cases;
|
by: Peter B. Steiger |
last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C
is a simple word game that involves stringing together random lists of
words. In the Pascal version the whole array was static; if the input
file contained more than entries, tough.
This time I want to do it right - use a dynamic array that increases in
size with each word read from the file. A few test programs that make use
of **List and realloc( List, blah...
|
by: Materialised |
last post by:
Hi everyone,
I seen the post by Rob Morris, and thought that I would double check
that I was using pointers in the correct way. So I written the following
string functions to test. I know soem can be iumplimented using the
standard libary, but I just wanted to test writing my own functions.
They work ok, but I would like some feed back on any issues you can see
with them etc
#include <stdio.h>
#include <stdlib.h>
|
by: bnoordhuis |
last post by:
Consider this:
int foo(int *a, int *b);
int (*bar)(void *, void *) = (void *)foo;
How legal - or illegal - is the typecast and are there real-world
situations where such code will cause trouble? I don't mean trouble
like in 'not compiling' but trouble like in 'crashing hard'.
| |
by: benjamin sago |
last post by:
Hello all. I am writing a command shell, but am having trouble with
memory allocations. I am trying to tokenise a string into a **char
array for execvp (the unix launch-this-program function), but I get
segmentation faults when I run it.
Here is the code that I use to parse the string, which fails:
char buf = "abcde fghij klmno"; /* sample string */
int arg = 0, pos = 0, i, in_string = 0;
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these in an
array. The application compiles but aborts without giving me any useful
information.
What I suspect is happening is infinite recursion. Each Directory
object creates an array of Subdirectories each of which has an array of...
|
by: JoeC |
last post by:
I understand the basics of pointers, they point to memory locations. I
would like to know resources for learning all about poters. I am
having some problems erasing elements of pointers from a vector. I
wold like to know where I can get some in depth information on how to
use pointers in various situations. It seems that all most books have
to say about pointers is that they point to memory locations. Some
even say they are...
|
by: Yee.Chuang |
last post by:
When I began to learn C, My teacher told me that pointer is the most
difficult part of C, it makes me afraid of it. After finishing C
program class, I found that all the code I wrote in C contains little
pointers, obviously I avoid using them.
A few days ago when I was reading a book about programming, I was told
that pointers are the very essence of C language, if I couldn't use it
well, I'm a bad programmer, it's a big shock.
So now I'm...
|
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...
|
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,...
| |
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...
|
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...
|
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();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |