Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-25-2009, 10:13 PM   #1
LQ Newbie
Registered: Apr 2009
Posts: 2

Rep: Reputation: 0
C++ help Dynamic array and "invalid conversion from ‘char’ to ‘char*’"

i have most of my code finished but im getting an error i dont understand "invalid conversion from ‘char’ to ‘char*’" and i need to write to a dynamic array and then output from it which i also dont know how to do. any help would be greatly appreciated. thanks for your time.

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

void rearrange (char *front, char *rear);

int main()
string input, word;
char *front, *rear;
vector <string> string;
cout << "Enter the string: ";
getline(cin, input);

istringstream break_apart(input);

while (break_apart >> word)
front = &;
rear = & - 1);
while (front <= rear)
rearrange (*front, *rear); // <--- heres where im getting my error
cout << word << " ";

return 0;

void rearrange (char *front, char *rear)
char temp = *front;
*front = *rear;
*rear = temp;
Old 04-25-2009, 10:15 PM   #2
LQ Newbie
Registered: Apr 2009
Posts: 2

Original Poster
Rep: Reputation: 0
well i was playing with it and i fixed my error but i still dont know what to for the dynamic array
Old 04-25-2009, 10:20 PM   #3
LQ Newbie
Registered: Mar 2009
Distribution: archlinux
Posts: 6

Rep: Reputation: 1
The problem is because your rearrange function takes two char pointers: *front and *rear. However, you are dereferencing front and rear when you call the function, therefore you're passing two chars by value when the function expects two pointers. To fix it, you're going to want to change the function call to

rearrange (front, rear);
That should fix your problem :-{D


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with "error: invalid conversion from `const char*' to `char*' " Linux - Newbie 11 02-11-2015 08:17 AM
about C++ invalid conversion from 'const char*' to 'char' teoporta Programming 3 07-17-2007 10:24 AM
invalid conversion from `const char*' to `char*' deepinlife Programming 22 08-05-2006 11:49 AM
If I get invalid conversion from `const char*' to `char' what should I be lookin for? RHLinuxGUY Programming 5 03-12-2006 11:35 PM
invalid conversion from `char' to `const char* bru Programming 6 05-09-2004 04:07 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration