RohitSahni 15 Light Poster

I will be starting working on perl and java soon..
Can anyone please help, form where to start so that i get the confidence of working on it and i can do hands on.

RohitSahni 15 Light Poster

001 00002 0000003 00004 000005 6 000007 008009
------------------------------------------------------------------------------------------------------
GBL UTG.L 0692861 DCGB 000000 0 205750 826UTG
GBL UU.L 0646233 DCGB 000000 0 722501 -371UU.

I have the above data line by line each and coloumn has fixed width then in those i want to assign 9 coloumns to variables reading each line at a time.
Can you pleae help me how the indexing of this is possible in C++.

RohitSahni 15 Light Poster

There is no "columns" There are tab sizes, but those only apply to the current session (also saved in preferences but only for the current user), so that doesn't help as the next person/viewer/editor won't have the same settings.

You best bet is, if your good at regex, to use search and replace to add in spaces. Even better, is to modify whatever "writes" the data to do that. Anyway, for vi, here:

http://www.cs.fsu.edu/general/vimanual.html

Here's the solution..
awk -F"~" '{printf("%-15s%s~%s\n", $1,$2,$3)}' inputfile
ID1 Name1~Place1
ID2 Name2~Place2
ID3 Name3~Place3

Thanks guys for your help..

RohitSahni 15 Light Poster

Depends on the editor.

i am using vi editor,....and want to send the file genrated as a mail...and want it to be in proper format

RohitSahni 15 Light Poster

mY QUERY IS RELATED TO..

How can i set coloumn width in unix...

Like for ex. i am having a file, whose content is like

------------------------------
aba bba baba
abba baba baaa
addd ffff fffff
-----------------------------------
i want it to be like
-----------------------------------
aba bba baba
abba baba baaa
addd ffff fffff
------------------------------------
How can i set the coloumn width in unix... Please reply asap.
Thanks

RohitSahni 15 Light Poster

Why we get the core file and also how can we debug it in unix(using sun C++ compiler)

RohitSahni 15 Light Poster

output:

$ tr "/v23.9" "/ABCDE" < test.txt
ABC
-p /home/user/a/b/ABCDE/library -l /home/user/a/b/ABC/ABCDE testDexe
DEF
-r ABCDE /c/d/f -p /home/user/a/b/ABCDE/library -l /home/user/a/b/ABC/ABCDE testDexe

i dont want these RED color items to change but want only green colur items.

RohitSahni 15 Light Poster

Hey there did you try tr and specify only alpha characters?

tr  '[:upper:]' '[:lower:]'

Hope that helps :)

, Mike

yup man i did tried this...but not working..

RohitSahni 15 Light Poster

Hi all,

The scenario is like this: i have one file which contains some particular paths, now my aim is to make changes in this file so that i can change the path in that file.. eg:

file1.txt:

ABC
-p /home/user/a/b/v23.9/library -l /home/user/a/b/ABC/v23.9 test.exe
DEF
-r v23.9 /c/d/f -p /home/user/a/b/v23.9/library -l /home/user/a/b/ABC/v23.9 test.exe

end of file1.txt

now i want to change only this 'v23.9' to 'abcde' that to only in both the paths.
I tried using "tr" but it changes all the v23.9 in this file.

Can anyone please suggest me any solution.

Thansk

RohitSahni 15 Light Poster

Hi All,

My query is related to assinging a variable with value which is there in the env.

Suppose from my c++ code i am doing putenv("A=abc"), now wat i want to do is to get this value of A in my shell script and assisng this "abc" to my shell variable, any idea how can i achieve this.

Thansk in advance.

RohitSahni 15 Light Poster

If anyone needs it let me know i will paste it.

Thanks .

RohitSahni 15 Light Poster

Guys i have made the neccasary changes, actually the code which i pasted earlier was the code written on very old version of C++(Borland). thats y those things were there but now the code is standardised so not a prob now.

Anyways Thank you all for showing so much enthu for this post.

Thanks once again. :)

RohitSahni 15 Light Poster

Yup Thanks,
I already updated it. Actually that was just a rough code .

RohitSahni 15 Light Poster

I was able to do it like this.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
void splitString(char inputstr[100])
{
	clrscr();
  //	char inputstr[100],
	char str[10][20];
  //	gets(inputstr);
	int i=0,j=0,k=0,l;
	while(inputstr[i]!='\0')
	{
		for(l=0;l<20;l++)
	{
		str[j][l]='\0';
	}
		str[j];
		while(inputstr[i]!=':')
		{
			str[j][k++]=inputstr[i++];
			if(inputstr[i]=='\0')
			{
				str[j][k+1]='\0';
				goto label;
			}
		}
		str[j][k+1]='\0';
		k=0;
		j++;
		i++;
	}
	label:
	for(i=0;i<=j;i++)
	{
		puts(str[i]);
		cout<<"\n";
	}
	getch();
}
void main()
{
char inputstr[100];
gets(inputstr);
splitString(inputstr);
}

If u can provide me with wat u have done, that will be help ful.
Thanks.

RohitSahni 15 Light Poster

Can anyone plz provide me with the sample code. Above one is not working for me.

Thanks in advance

RohitSahni 15 Light Poster

Hi all,

Suppose i have one string as "A:B:C", where ":" is the delimiter . now i want to seperate this A, B, and C and save them in 3 different variables.

How can i implement this thru C++ code.

Plz let me know.

Thanks in advance.

RohitSahni 15 Light Poster

Yes it is a console process.
i am using Unix and using Sun C++ compiler
and also i am using GUI.

RohitSahni 15 Light Poster

Hi All,

I am writing a code in C++ to implement Login screen which will accept user name and password from the user. Now my main concern is to hide that password to be sceen by the user.

suppose my password is "Rat420" so at the time of typing anything i want it to appear as "******".

That means i need "*" to be seen on screen for each and ever character, and the original password is not lost.

RohitSahni 15 Light Poster

I am calling one c++ exe from my unix shell script, i am trying to set the env variables using putenv() thru my c++ code. Now i want to use these varibles in my new exe which is there in the same shell script(set by using the previous exe ) , but i am not able to access those varibles..

Please help me out in this.


flow of the script. :

one c++ exe (putenv("ABC=a") variable)
|
(when i am doing echo $ABC in the script i am not able to get its value and also i am not able to getenv this variable value)
|
V
second c++ exe of different version compiler (Here i want to get the already set env variables.)

I am not able to do that

RohitSahni 15 Light Poster

Hi All,
I am calling one exe from my c++ code exe, now i want some(two or three) values in my c++ code exe from that exe which i am calling,

Any idea how can it be done?

Plz help me out in this.

RohitSahni 15 Light Poster

Which version are you using? looks like it is not compatible with your compiler version.

i am using Compiler "/sbcimp/run/tp/sun/SUNWspro/v8/bin" i.e version 5.5 Sun C++ compiler.

and you can see it is refreing to "/sbcimp/run/tp/sun/SUNWspro/v8/prod/include/CC/Cstd/rw/rwdispatch.h"

And yes i am trying to port some of the files which are previously build on v4.2.p3 sun compiler to 5.5 version.

Any suggestions plz.

RohitSahni 15 Light Poster

i am getting this error :

"../incl/GDS_Thread/Thread.h", line 141: Warning (Anachronism): Formal argument 3 of type extern "C" void*(*)(void*) in call to pthread_create(unsigned*, const _pthread_attr*, extern "C" void*(*)(void*), void*) is being passed void*(*)(void*).
"../incl/GDS_Thread/Thread.h", line 221: Warning (Anachronism): Formal argument 2 of type extern "C" void(*)() in call to pthread_once(_once*, extern "C" void(*)()) is being passed void(*)().
"/sbcimp/run/tp/sun/SUNWspro/v8/prod/include/CC/Cstd/rw/rwdispatch.h", line 63: Error: _RW_is_integral_type(int) already had a body defined.
"/sbcimp/run/tp/sun/SUNWspro/v8/prod/include/CC/Cstd/rw/rwdispatch.h", line 121: Error: Multiple declaration for _RWdispatch<int>.
"Sql.cc", line 653: Warning: String literal converted to char* in formal argument buf in call to ct_command(_cscommand*, long, char*, long, long).
2 Error(s) and 3 Warning(s) detected

Any idea how can i resolve it.
Thanks.

RohitSahni 15 Light Poster

Hi All,

I am working on a situation suppose i am calling one exe(C++ code) from unix shell script now i want that 2 values in that unix script which this c++ code will get from some URL.
Any Idea how can i get those 2 values from C++ code exe to unix shell script.

Thnks
Rohit

RohitSahni 15 Light Poster

I am trying to build exe bbut getting the following above said error..
I am tring to build below mention code.

#include <iostream>
#include <fstream.h>
#include <stdlib.h>

#include "RohitSahni/String.h"

using namespace std;
int main(int argc, char **argv)
{
			String testString("Hellow");
			cout << "*********"<<testString.c_str();
			
			
    			
   }

In the above code i have defined my own String claa inherited from std::string.

Plz Help

Thanks
Rohit

Ancient Dragon commented: Thanks for using code tags +15
RohitSahni 15 Light Poster

Hi All,
Please Help me out with this below mentioned error.

librohit.a: undefined reference to `MODEL_NAME'
librohit.a: undefined reference to `FT_MODEL'
librohit.a: undefined reference to `STOCK_MODEL'
librohit.a: undefined reference to `FUTURE_MODEL'
librohit.a: undefined reference to `COArgs::COArgs()'
librohit.a: undefined reference to `std::strstreambuf::freeze(int)'
librohit.a: undefined reference to `RWMutex::wLock()'
librohit.a: undefined reference to `OUTSTRIKE_PARAMETERS'
librohit.a: undefined reference to `sec_login_sql_client'
librohit.a: undefined reference to `sec_login_ctor'
librohit.a: undefined reference to `RWMutex::wUnlock()'
librohit.a: undefined reference to `RWMutex::rLock()'
librohit.a: undefined reference to `RWMutex::rUnlock()'
librohit.a: undefined reference to `String::String(char)'
librohit.a: undefined reference to `String::hashval() const'
collect2: ld returned 1 exit status

Thanks
Rohit

RohitSahni 15 Light Poster

Hi all,

Plz helpme out with this error.

I am trying to Port my C++ compiler from Sun C++ compiler to GNU gcc 3.4.2 and i am getting below errors..Guys any idea how to solve this.

In file included from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/stl_algobase.h:72,
                 from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/char_traits.h:46,
                 from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/ios:46,
                 from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/ostream:45,
                 from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/iostream:45,
                 from /sbcimp/run/pd/gcc/3.2.1/include/c++/3.2.1/backward/iostream.h:32,
                 from ../../incl/GDS_Components/COMap.h:14,
                 from ../../incl/GDS_Components/CallbackManager.h:10,
                 from CallbackManager.cc:6:
/sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/type_traits.h:196: error: redefinition of `struct __type_traits<int>'
/sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/type_traits.h:126: error: previous definition of `struct __type_traits<int>'
/sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/type_traits.h:347: error: redefinition of `struct _Is_integer<int>'
/sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/type_traits.h:305: error: previous definition of `struct _Is_integer<int>'
In file included from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/locale_facets.tcc:38,
                 from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/locale:47,
                 from /sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/include/c++/bits/ostream.tcc:40,

Thanks
Rohit

RohitSahni 15 Light Poster

Hi all,

fstream filestr ("test.txt", fstream::in | fstream::out);

Plz confirm me about the permission on "test.txt".
it will be '777' by default ..am i thinking correct.?

RohitSahni 15 Light Poster

Actually this is the String class(i derived this class from ) defined by me only..and i included its '.h' in the respective file i.e DBRes.cc.

Then why i am getting this error.

RohitSahni 15 Light Poster

Hi All,

In file included from ../../incl/_Components/DbRes.h:7,
                 from DbRes.cc:1:
../../incl/_Components/IniReader.h:79:8: warning: extra tokens at end of #endif directive
/sbcimp/run/pd/gcc/3.4.2-32bit/lib/gcc/sparc-sun-solaris2.8/3.4.2/crt1.o(.text+0x5c): In function `.nope':
: undefined reference to `main'
/var/tmp//ccA4edOw.o(.text+0x84c): In function `DbRes::Lock::Lock(String const&, String const&)':
/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:65: undefined reference to `String::String(char const*)'
/var/tmp//ccA4edOw.o(.text+0x8c4):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:65: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0x8e4):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:65: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0x934):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:70: undefined reference to `String::String(char const*)'
/var/tmp//ccA4edOw.o(.text+0x9b4):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:70: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0x9d4):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:70: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0xb40):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:80: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0xb60):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:80: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0xd60): In function `DbRes::Lock::Lock(String const&, String const&)':
/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:65: undefined reference to `String::String(char const*)'
/var/tmp//ccA4edOw.o(.text+0xdd8):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:65: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0xdf8):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:65: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0xe48):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:70: undefined reference to `String::String(char const*)'
/var/tmp//ccA4edOw.o(.text+0xec8):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:70: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0xee8):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:70: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0x1054):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:80: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0x1074):/home//Developer/__local_unix/_/lib/_Components/DbRes.cc:80: undefined reference to `String::~String()'
/var/tmp//ccA4edOw.o(.text+0x1360): In function `DbRes::DbRes(String const&, String const&, int)':

Guys i am getting this error..Any idea why i am getting these errors, plz help me out in this.

RohitSahni 15 Light Poster

Thanks a lot for your Rply..i will be using atoi().
And it worked for me. :)

RohitSahni 15 Light Poster

Hi All,

I want to convert char * to int.

Plz help me out.

Thanks in advance.

RohitSahni 15 Light Poster

i found setb,setp and setg in iostream.h of sunCompiler C++4.2..
Can anyone tel me its equivalent in gcc3.4.2. Coz i just cant see setb setp and setg in <iostream>...

Plz help me out..

RohitSahni 15 Light Poster

hi any idea about this error.

In constructor `local_ExtraLogStreamBuf::local_ExtraLogStreamBuf()':
.cc:224: error: `setb' undeclared (first use this function)
.cc:224: error: (Each undeclared identifier is reported only once for each function it appears in.)
/usr/include/time.h: In member function `void local_ExtraLogStreamBuf::printAtLogLevel(char, const char*)':
/usr/include/time.h:250: error: too many arguments to function `char* asctime_r(const tm*, char*)'
.cc:284: error: at this point in file

This is because of setb(char *,char*) function, which i think we are not able to find in the headers which i included.The snippet is below:

#include <iostream.h>
#include <time.h>
#include <thread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <strstream.h>

local_ExtraLogStreamBuf::local_ExtraLogStreamBuf() : streambuf()
{
   
      // set up buffer    
    // buffer +4 because due to processing we might want to write one byte
    // past end of streambuf end...
    _ptr = new char[BUFFERSIZE + 4]; // create buffer to write info....
    setb(_ptr, _ptr + BUFFERSIZE);
    setp(0,0);
    setg(0,0,0);  
  
}

And plz let me know in which header file i can get this stb(),setp, and setg() functions.
Plz help me out ..thank in advance.

RohitSahni 15 Light Poster

Hi Guys..
Plz let me know where can i get STL string user guide.
and d also if u guys can help me.


I want to know is there any method in std::string which can help me convert Lower caase to upper case and vice verssa.

Plz help me out with this. thanks..

RohitSahni 15 Light Poster

Suppose while converting RWCString constructors to std::string constructors, i am getting following errors. Can anyone please povide me with the Porting Guide for this .error which i am getting :

Hash.h:23: error: 'const struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >' has no member named 'hash'
COArgs.cc: In member function `void COArgs::readStream(std::istream&)':
COArgs.cc:221: error: no match for call to `(std::string) (size_t&, char)'
COArgs.cc:222: error: no match for call to `(std::string) (unsigned int, unsigned int)'
COArgs.cc:251: error: no match for call to `(std::string) (int, size_t&)'
COArgs.cc:252: error: no match for call to `(std::string) (unsigned int, unsigned int)'
COArgs.cc:317: error: no match for call to `(std::string) (unsigned int, unsigned int)'

And also Rogue Wave Provides us with the Hash Function, Can anyone also tell me its equivlant in STL.