Search Results

Search: Posts Made By: johnbach
Forum: Programming 07-29-2010
2,169
Posted By johnbach
$cat ts.C #include<iostream> #include<time.h>...
$cat ts.C
#include<iostream>
#include<time.h>
using namespace std;
int main()
{
clock_t start = clock();
int i=9*8;
while(i--)
{
int j=9999999;
while(j--);
}
clock_t end = clock();...
15,413
Posted By johnbach
the output should be one Ok this works in...
the output should be
one

Ok this works in bash
#!/bin/bash

cell1="one"
cell2="two"
cell3="three"

i=1

while [ $i -lt 4 ]
do
var_name="cell"$i
echo ${!var_name}
i=`expr...
15,413
Posted By johnbach
dynamic variable name
I found one post in another site with a solution for my problem
the below solution should explain what I want.


#!/bin/sh

first="one"
second="two"
third="three"

myvar="first"
echo...
Forum: Programming 07-27-2010
2,169
Posted By johnbach
problem with clock()
#include<iostream>
#include<time.h>
using namespace std;
int main()
{
system("date");
clock_t start = clock();
int i=9*8;
while(i--)
{
int...
1,877
Posted By johnbach
Fastest way to delete line
I have a 5 GB text file(log/debug)
I want to delete all lines containing 'TRACE'
Command used
sed -i '/TRACE/d' mylog.txt

Is there any other fastest way to do this?
Forum: IP Networking 03-05-2010
2,480
Posted By johnbach
false tcp connection
Why this happens?
How to solve this?
$netstat -na |grep 9325
tcp 0 0 127.0.0.1:9325 127.0.0.1:9325 ESTABLISHED

When a client socket repeatedly tries to...
Forum: Programming 02-09-2010
1,324
Posted By johnbach
Try this while (getline (myfile,templine) ) ...
Try this

while (getline (myfile,templine) )
line.append(templine);

size_t pos;
while( (pos=line.find("as"))!=string::npos)
line.replace(pos,2,"\n");
cout<<"o/p :"<<line<<"\n";

...
Forum: Programming 12-03-2009
2,647
Posted By johnbach
Ok ,this is the reduced version of my actual code...
Ok ,this is the reduced version of my actual code to simulate this error

class Connection
{
int fd,ctr;
struct hostent *he;
struct sockaddr_in host;
int...
Forum: Programming 11-26-2009
2,647
Posted By johnbach
1. No ,cout will not be reached if connect...
1. No ,cout will not be reached if connect fails(return -1)
2. I don't have any application(server socket) listening on port 9102
3. Please look into the netstat o/p, both the endpoints are same
Forum: Programming 11-26-2009
2,647
Posted By johnbach
Client socket
Am trying to connect to local machine on port 9102
There is no server application listening on port 9102.

if (connect(fd,(struct sockaddr *)&addr, (socklen_t)sizeof(struct sockaddr)) == -1)
...
7,961
Posted By johnbach
Revert SVN import
Instead of importing a project/folder as
svn import vlsms/ file:///home/repo/vlsms -m "Initial Upload"
I did
svn import vlsms/ file:///home/repo -m "Initial Upload"

How to undo this import (in...
Forum: Programming 09-17-2009
7,509
Posted By johnbach
Optional/DEFAULT non-const reference argument c++ ?
Is it possible to have a non-const reference variable as an OPTIONAL/DEFAULT parameter to c++ function
ex
void read(string &data,int &type=0 /*or something*/) ;
so i will call

read(data);...
Forum: Programming 09-11-2009
3,734
Posted By johnbach
SSL over TCP/IP
I am trying to develop a c++ application which will communicate with client through SSL(Not https).We are using self-signed certificates.

I have installed openssl and boost library.
I have tried...
2,526
Posted By johnbach
decryption using digital certificate
A client application is encrypting a text using private key and sends through socket.

My application(server written in c/c++,unix) receives the chiper-text through socket.
I have client's digital...
Forum: Programming 08-26-2009
1,498
Posted By johnbach
stl map - could any one explain the o/p
class tst
{
public:
tst() {
cout<<"ctor tst()\n";
}
tst(const tst& ob) {
cout<<"cp ctor tst()\n";
}
~tst()
{
cout<<"dtor...
Forum: Programming 08-13-2009
5,875
Posted By johnbach
Thanks, I also got one more soln. from another...
Thanks,
I also got one more soln. from another forum
ioctl( sock_fd, SIOCINQ, &numBytes )
Forum: Programming 08-13-2009
5,875
Posted By johnbach
Finding used socket receive-buffer size
I have set the receive buffer size of socket to max.
setsockopt(sd,SOL_SOCKET, SO_RCVBUF,&max,optval);
Am reading data from the socket in a loop(say max 100 bytes per recv)
while(1)
{
int...
Forum: Programming 08-12-2009
2,912
Posted By johnbach
Thanks for your time in explaining me with an...
Thanks for your time in explaining me with an example.
Forum: Programming 08-11-2009
2,912
Posted By johnbach
STL Iterator and user-defined class
Is is possible to make STL-Iterator to work with user defined class ,like the one below?
#include <iostream>
#include <stdexcept>
using namespace std;
template <class T>
class Array
{
...
Forum: Programming 08-10-2009
5,835
Posted By johnbach
C++ overriding Vs hiding
class B
{
public:
void fns(void){//base def;}
};
class D:public B
{
public:
void fns(void) {//new def;}
};

I was thinking the above is overriding but somewhere else i found the above is...
Forum: Programming 08-07-2009
3,467
Posted By johnbach
C++ inserting data in a file
Could anyone help me with an efficient(and easy) way to insert data in a file directly(with out using temp file).

example
open the file1.txt

11112222
333333
44444444



and insert...
4,797
Posted By johnbach
You awk may not support -v option try nawk,gawk
You awk may not support -v option
try nawk,gawk
6,985
Posted By johnbach
If there are lot of files,its definitely going to...
If there are lot of files,its definitely going to utilize more cpu

I believe the below form is more efficient
find /abc/def -name '0*.txt' -mtime +6 |xargs rm
and if you don't want this script...
15,921
Posted By johnbach
echo '<ABC>Hello</ABC><BCD>How r u?</BCD><CDE>GOD...
echo '<ABC>Hello</ABC><BCD>How r u?</BCD><CDE>GOD Bless u</CDE>' |sed 's/<\/[^>]*>/&\n/g'
1,931
Posted By johnbach
jb>ls 02082009 03082009 04082009 05082009 ...
jb>ls
02082009 03082009 04082009 05082009 25072009 30052009
jb>ls |sort -k1.5,1.8 -k1.3,1.4 -k 1.1,1.2 |tail -1
05082009
jb>
Showing results 1 to 25 of 61

 

Featured Tech Videos

All times are GMT -4. The time now is 05:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy