Prabakar 77 Posting Whiz

Alright, now run it again. I'll bet you 20 fictional bucks that it won't output that exact same thing again :) (well eventually it will once every gazillion times or so)

prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOFOURONETWOONETWOONETWOFOURFOURONETWOONETHREEONETWOONETHREEONETWOONETWO
ONETWOONETWOFOURONETHREEONETWOONETWOONETHREE
prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOFOURONETWOONETWOONETWOFOURFOURONETWOONETHREEONETWOONETHREEONETWOONETWO
ONETWOONETWOFOURONETHREEONETWOONETWOONETHREE
prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOFOURONETWOONETWOONETWOFOURFOURONETWOONETHREEONETWOONETHREEONETWOONETWO
ONETWOONETWOFOURONETHREEONETWOONETWOONETHREE

Now what was the bet? :D
To tell the truth I did not even care to read the program at first and I would admit that yes, indeed, I cannot assure that, it would be the answer every time.

Nick Evan commented: Here's 20 bucks :( +16
Prabakar 77 Posting Whiz

That's what I will do. But it is up to you.

Prabakar 77 Posting Whiz

ummmm....
how can you giv print to a single variable var with %s specifier???

your problem shouldn't be in the code but the definition of var[]!

We don't know how it is declared, do we? It might be a 2D array or an array of Pointers or may be even vectors, the op should give more details if he/she wants a good answer

Salem commented: Yeah, that and many other possible horrors +28
Prabakar 77 Posting Whiz

Sorry to have suggested an untested code.
My little Google search found me this

Have a look at it.

This time I have tested the code and it really works.

ShellExecute(GetDesktopWindow(), "open", "\"D:\\program files\\Adobe Reader 9.exe\"", "/A page=45 Ubuntu.Pdf", NULL, SW_SHOWNORMAL);

D:\Program files\Adobe Reader 9.exe is the path to the portable reader in my computer(I always try to get portable versions).

Ubuntu.pdf was in the same folder as my CPP program, hence I did not specify its path.

Details about parameter options could be found int the link above.

Good Luck

marcosjp commented: Very helpful, saved my day with a great solution +1
Prabakar 77 Posting Whiz

Thanks for your help. The project is completed:)
It works fine. I did get stuck when the client had to return a message to the server but google helped me get the answer:)

Alex Edwards commented: That's right!! Google it! +4
Salem commented: Congrats +21
Prabakar 77 Posting Whiz

1) the overloaded operator << return a reference to the fin object
2) type casting to primitive data type is as follows.

class complex
{
       int r, i ;
public :
       operator int()
       {
           return r*r-i*i ; // some conversion to int
       }
       complex():r(0), i(0) { }
       complex ( int a, int b ) { r = a; i = b ; }
      
};

if both the source & destination are user defined then the function for the cast may be either in source ot in destination.
Conversion routine in source is similar to that of the primitive types. But in destination is a little different.

class dmy // source
{
    int day, mth, yr ;
 //methods
} ;
class date // destination
{
    char a[10] ;
// conversion routine
   public:
    date ( dmy t ){/*convert ints to char array*/}
};

Hope this helps:)

Prabakar 77 Posting Whiz

I am confused looking at this thread. To convert a lower case letter to upper case I always subtracted 32 from the lowercase letter. Adding 48? Is this correct or is it a mistake.
Please reply.

jephthah commented: good catch +1
Nick Evan commented: Thanks for the correction. You're right +6
Prabakar 77 Posting Whiz
#include <stdio.h>
#include<string.h>
int main ()
{
      char firstipadd[20], fname[30] = "D:\\";
      FILE *pFile;;
      pFile = fopen ("D:\\xyz.txt" , "r");
      fseek(pFile,169,SEEK_SET);
      fgets (firstipadd , 14 , pFile);
      fclose (pFile);
      strcat ( fname, firstipadd) ;
      rename ( "D:\\xyz.txt", fname ) ;
      getchar ( ) ;
}

This code is working for me for your txt file.
However, I dont like the idea of using fseek like this.
I would prefer reading the file char by char.
But since you are in a hurry, I'll give this for now.