LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 10-01-2010, 11:27 AM   #1
shetty
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
problem with library


#include"iostream.h"
#include<conio.h>
#include "string.h"

int main()
{
int lenM;
char str[]="test";
int len=strlen(str);
int i;
for(i=0;i<len;i++)
{
cout<<str[i]<<i[str]<<*(str+i)<<*(i+str);
}
lenM=len/2;
len--;
for(i=0;i<lenM;i++)
{
str[i]=str[i]+str[len-i];
str[len-i]=str[i]-str[len-i];
str[i]=str[i]-str[len-i];
}
cout<<"string reversed\n";
}


when i try to compile this program i am getting error as shown below pleae help me
string.cc:1:21: error: iostream.h: No such file or directory
string.cc:2:18: error: conio.h: No such file or directory
string.cc: In function ‘int main()’:
string.cc:13: error: ‘cout’ was not declared in this scope
string.cc:23: error: ‘cout’ was not declared in this scope
 
Old 10-01-2010, 12:05 PM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by shetty View Post
string.cc:1:21: error: iostream.h: No such file or directory
string.cc:2:18: error: conio.h: No such file or directory
string.cc: In function ‘int main()’:
string.cc:13: error: ‘cout’ was not declared in this scope
string.cc:23: error: ‘cout’ was not declared in this scope
  1. iostream.h is supposed to be just "iostream"
  2. conio.h is a Windows/DOS header - I don't know what functions you want from it, but you don't seem to be using any I've not seen in standard headers, so just remove this line
  3. cout is in the std namespace - either use std::cout or put "using namespace std;" after your #includes.
 
Old 10-01-2010, 02:32 PM   #3
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Quote:
iostream.h is supposed to be just "iostream"
<iostream> since it's a standard header
 
Old 10-01-2010, 02:51 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

JohnGraham is right:
1. You shouldn't be using "conio.h" (that's a DOS header that doesn't even exist on Linux).

2. You should use "iostream" and "string" instead of "iostream.h" for C++ (since sometime in the 1980's).

3. You should be using <> instead of "" for system headers.

4. You should be using C++ "string" types instead of C "char[]" arrays.

Etc.

Here's a revised, simplified snippet:
Code:
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int
main(int argc, char *argv[])
{
  string str("test");
  cout << "str: " << str << endl;
  cout << "length(str): " << str.length () << endl;
  string strr = str;
  reverse (strr.begin(), strr.end());
  cout << "reverse(str): " << strr << endl;
  return 0;
}
Quote:
g++ -o tmp -Wall -pedantic tmp.cpp

./tmp =>
str: test
length(str): 4
reverse(str): tset
 
1 members found this post helpful.
Old 10-01-2010, 11:22 PM   #5
shetty
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for the answers.
 
  


Reply



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
ldd reports shared library missing, but library exists on disk athv_gr Linux - Newbie 7 05-13-2009 12:31 PM
install from source - unable to find the libcurl library - but library is installed pulper Linux - Newbie 2 02-23-2009 09:00 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
Shared library problem (BIG problem) jlg Slackware 1 03-25-2003 10:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:33 PM.

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