473,409 Members | 2,006 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,409 software developers and data experts.

system( char(26)) error

Hello
I have this line in my c++ code and it is giving the error below, not
sure why, I tried it on different boxes, same error. thanks

the last line in my main() I have this
system( (char(26));
error: invalid conversion from 'char' to 'const char*'
Jul 23 '05 #1
7 3598
Baloff wrote:
Hello
I have this line in my c++ code and it is giving the error below, not
sure why, I tried it on different boxes, same error. thanks

the last line in my main() I have this
system( (char(26));
error: invalid conversion from 'char' to 'const char*'


What's not to understand? The function system() wants a const char *,
but you passed it a single char. What are you trying to accomplish?

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays
*If it belongs to `it' it's `its'.*
Jul 23 '05 #2
Baloff wrote:
Hello
I have this line in my c++ code and it is giving the error below, not
sure why, I tried it on different boxes, same error. thanks

the last line in my main() I have this
system( (char(26));
error: invalid conversion from 'char' to 'const char*'


The error is quite clear. The footprint for system() is

int system(const char *);

You're passing a char to a function expecting a const char *.

Why are you trying to pass a ctrl-Z?

If you really want to do that, try:

system("\032");
Jul 23 '05 #3
Baloff wrote:
Hello
I have this line in my c++ code and it is giving the error below, not
sure why, I tried it on different boxes, same error. thanks

the last line in my main() I have this
system( (char(26));
error: invalid conversion from 'char' to 'const char*'


char(26) creates a temporary object of type char and initializes it with
the value 26. system() takes a const char * as an argument. Thus your
error. Without knowing what you were attempting to do nothing useful
can be said about how to fix your error.

More errors, your parentheses aren't correctly matched, and the last
line in main() should under most circumstances be a return statement.

Alan
Jul 23 '05 #4
Baloff wrote:
I have this line in my c++ code and it is giving the error below, not
sure why, I tried it on different boxes, same error. thanks

the last line in my main() I have this
system( (char(26));


What do you expect it do do? What made you think that syntax would do
anything?

What does the online help and tutorials tell you about system?

What does using Google or Google Groups tell you about system()?

What do the examples look like?

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #5
Phlip wrote:
Baloff wrote:

I have this line in my c++ code and it is giving the error below, not
sure why, I tried it on different boxes, same error. thanks

the last line in my main() I have this
system( (char(26));

What do you expect it do do? What made you think that syntax would do
anything?

What does the online help and tutorials tell you about system?

What does using Google or Google Groups tell you about system()?

What do the examples look like?

I only took this code from Thinking in C++ Vol-1 and it did not compile
because of this error. I noticed this line "system(char(26))" in more
than one code in the few 3 chapters of the book. and since it is a book
with some good reputation, I did not think it would be incorrect. but it
looks I have to do some homework.

thanks
Jul 23 '05 #6
On 2005-07-21 20:17:43 -0400, Baloff <vd****@bi.edu.gr> said:
I only took this code from Thinking in C++ Vol-1 and it did not compile
because of this error. I noticed this line "system(char(26))" in more
than one code in the few 3 chapters of the book. and since it is a book
with some good reputation, I did not think it would be incorrect. but
it looks I have to do some homework.


Are you sure about that? I'm looking at the PDF version of the book
right now, and can't find that text anywhere. In fact, the only
reference to the system() function that I can find in any sample code
is on page 108:

//: C02:CallHello.cpp
// Call another program
#include <cstdlib> // Declare "system()"
using namespace std;

int main() {
system("Hello");
} ///:~

--
Clark S. Cox, III
cl*******@gmail.com

Jul 23 '05 #7
Clark S. Cox III wrote:
On 2005-07-21 20:17:43 -0400, Baloff <vd****@bi.edu.gr> said:
I only took this code from Thinking in C++ Vol-1 and it did not
compile because of this error. I noticed this line "system(char(26))"
in more than one code in the few 3 chapters of the book. and since it
is a book with some good reputation, I did not think it would be
incorrect. but it looks I have to do some homework.

Are you sure about that? I'm looking at the PDF version of the book
right now, and can't find that text anywhere. In fact, the only
reference to the system() function that I can find in any sample code is
on page 108:

//: C02:CallHello.cpp
// Call another program
#include <cstdlib> // Declare "system()"
using namespace std;

int main() {
system("Hello");
} ///:~

a while back I downloaded the book, I have now a directory with the
source codes, in the files for chapter 3, I could find these 2 programs.
//////////////////////////////////////////////////
//: C02:CallHello.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Call another program
#include <cstdlib> // Declare "system()"
#include <iostream>
using namespace std;

int main() {
system("date");
cin.sync(); cin.get(); return 0;
} ///:~
///////////////////////////////////////////////////
//: C03:Ifthen.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Demonstration of if and if-else conditionals
#include <iostream>
using namespace std;

int main() {
int i;
cout << "type a number and 'Enter'" << endl;
cin >> i;
if(i > 5)
cout << "It's greater than 5" << endl;
else
if(i < 5)
cout << "It's less than 5 " << endl;
else
cout << "It's equal to 5 " << endl;

cout << "type a number and 'Enter'" << endl;
cin >> i;
if(i < 10)
if(i > 5) // "if" is just another statement
cout << "5 < i < 10" << endl;
else
cout << "i <= 5" << endl;
else // Matches "if(i < 10)"
cout << "i >= 10" << endl;
system( char(26)); //<-- this line is not in the book but in the
source code bundled with the book according to the content of the file
in the folder, "assuming I did not modify it some time ago and forgot".
} ///:~
///////////////////////////////////////////////////////
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eric Diana | last post by:
I am trying to place an strings into an array of strings I am declaring as Dim Fields() As String I have another variable im doing the same thing with and it works. Public Shared Operations()...
12
by: Jamie Ruff | last post by:
I am having problems with making system calls on Windows under Cygwin that involve the use of redirection operators and pipes. For example, the line below will cat two files, but the next command...
1
by: JVince | last post by:
Hi y'all upon compiling the code the application seems to be running okay from the c:\app\bin folder. When I try to distribute the application to a new folder (ie c:\prog) I get the JIT...
1
by: Ripul Handa | last post by:
Hi We are running IIS 5.0 cluster with cisco local director. We are running a website on 2 webservers and I have been observing that from past few days we have are getting this error message of...
2
by: Michael | last post by:
Hello all and thanks in advance, I'm running a vb.net program and part of it copies files from one server to another. It generally works fine but once in a while I get this error: ...
8
by: John | last post by:
Hi I am getting this error when running a project; An unhandled exception of type 'System.ExecutionEngineException' occurred in system.dll What can I do to fix this problem? Using vs.net...
11
by: darrel | last post by:
I'm modyfying an image upload and resizing script that we've had laying around for a long while. I'm getting a NullReferenceException error (see full error at bottom) from this line: Dim g...
0
by: Mike | last post by:
Hi, I have a collection object bound to a data grid, after I remove an item from the collection, the minute I click on the datagrid I get an error saying the specified argument was out of the...
0
by: smugcool | last post by:
hi, I have made a project on vb 6.0. And i have made a setup file for the same. When i am runing this file in WINDOWS XP, its running absolutly fine. But the same setup file when i try to run...
1
by: JDS | last post by:
I am getting the following error in my application: System.UnauthorizedAccessException was unhandled Message="Access to the port is denied." Source="System" StackTrace: at...
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
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
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...
0
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...
0
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,...
0
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...
0
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...

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.