Freaky_Chris 299 Master Poster

Im guessing you mean in relation to realy time, you may want to use CLOCKS_PER_SEC to get things in terms of time and in terms of time to clocks for example divide clock()/CLOCKS_PER_SEC withh give you how many seconds, etc and if you want to wait for x seconds do seconds*CLOCKS_PER_SEC

Chris

Freaky_Chris 299 Master Poster

usethe string header so you can get the path from the user then pass it to chdir like this

chdir(path.c_str());

Chris

Freaky_Chris 299 Master Poster

Yet another tip: you can get "mirrored" char with only one and a very simple expression without any explicit numbers...

Now thats a new one to me, normally i can thing of these thing straight off the top of my head. But not this one lol otherwise i would of suggested it. I spend quite a bit of time finding quickest ways to do things but this one got me :P

Freaky_Chris 299 Master Poster

i would suggest looking at the ascii code for the character. To start with the ascii code for 'A' is 65 and for 'Z' is 90, there rest lie inbetween unsuprisingly. You first step would be to determine ig it is on the right or left hand side. So is it <= 77 or >=78 once you have this then you can carry on.

Once you have done that then you can go about subracting, and adding values to and from the numbers 65 and 90. I'm not going to go into too much detail ill leave you with something to think about.

If you get stuck with it then we can provide more help. But that should be more than enough help for now

Chris

Freaky_Chris 299 Master Poster

No there isn't and again no.
You would have to write your own. Search the forums its a VERY popular question.

It will turn up alot of material for you to look at, including recursive and non-recursive.

Chris

Freaky_Chris 299 Master Poster

menu (char symbol); Should be menu (symbol); Chris

Freaky_Chris 299 Master Poster

count your opening and closing brackets

Freaky_Chris 299 Master Poster

using console redirection is not how to read from a text file, http://www.cplusplus.com/doc/tutorial/files.html

is an example of how to read from a text file although it incourages bad things such as while ( !eof ) and .is_open().

But thats for another day

Chris

Freaky_Chris 299 Master Poster

just a note on the loop

while (STAMINA || ENM_STAMINA != 0 )

I'm not to sure what you think this means exactly (althought its ok this time), but im guessing its not what it actually means. it would be evaluated as follows

while ((STAMINA) || (ENM_STAMINA != 0) )

not

while ((STAMINA || ENM_STAMINA) != 0 )

Hope that makes sense

Chris

Freaky_Chris 299 Master Poster

windows.h has a Sleep() function, this will allow you to stall the application for a short period of time each loop, thus reducing the processor usage to 0 or almost.

Chris

Freaky_Chris 299 Master Poster

You could redirect it to a text file, and then read the text file or examine pipes.

system("ping anipaddress > %TEMP%textfile.txt")

Then read the text file. thats the simpler option the better option would probably be pipes.

Chris

Freaky_Chris 299 Master Poster
std::cin >> ipadd;
commandArg = "ping " + ipadd.c_str();
system(commandArg);

Something along those lines should do you nicely. c_str() is in the string header btw.

Chris

Freaky_Chris 299 Master Poster

im not gonna comment on errors in your code, since this may just be purposefull...

#include <ctime>

srand( (unsigned) time(NULL) );

randomnumber = rand() % 3 + 1;

that should give you a random number between 1 & 3.

Chris

Freaky_Chris 299 Master Poster

That looks right to me, next state it to convert that into code, be it C++ or psuedo.
do each point indervidually, don't try and mix them up.

Chris

Freaky_Chris 299 Master Poster

No, there is not standard C++ method of doing this, or at least not that im aware of. If your using linux i believe the ncurses or pdcurses headers may have something to heklp you out. If your on windows then you can use windows.h

ReadConsoleOutputCharacter(
  __in   HANDLE hConsoleOutput,
  __out  LPTSTR lpCharacter,
  __in   DWORD nLength,
  __in   COORD dwReadCoord,
  __out  LPDWORD lpNumberOfCharsRead
);
#include <iostream>
#include <windows.h>

int main(void){
   HANDLE hOut;
   COORD location = {3, 5};
   char letter;
   DWORD numberRead;

   hOut = GetStdHandle(STD_OUTPUT_HANDLE);

   ReadConsoleOutputCharacter(hOut, &letter, 1, location, &numberRead);

   std::cout << letter;

   std::cin.get();
   return 0;
}

Hope that helps, note untested.

Chris

Freaky_Chris 299 Master Poster

You should have a read about functions and parameters.

#include <iostream>

int Plus(int x, int y){
    return x + y;
}

int main(){
    int number;
    int number2;
    char op;
    
    std::cout << "type in a number" << std::endl;
    std::cin >> number;
    
    std::cout << "another number" << std::endl;
    std::cin >> number2;
    
    std::cout << "+, - , * or /?" << std::endl;
    std::cin >> op;
    
    if(op == '+'){
            std::cout << Plus(number, number2) << std::endl;
            }
            
    system("pause");
    return 0; 
}

I should point out you cannot read a '+' sign into an int, hence why i changed it to a char. Also you cannot use 'do' as a variable name as it is a command used in do..while loops.

Chris

edit:: damn 4 posts at once!

Freaky_Chris 299 Master Poster

Not my first or second choice. atoi() falls short at error handling.
strtol() is a better alternative.

That is too true, i'm glad you pointed that out. strtol() may prove helpful to me thanks.

Chris

Freaky_Chris 299 Master Poster

If you are looking to convert strings and into integers, you may want to check out the atoi() function.

Chris

Freaky_Chris 299 Master Poster

Trying looking at how notepad is called from the registry command when you open a file, that tells you what to do for your application, if you apply some common sense.

> will the first argument be the file name from which the program has been called?
Yes.

I have a feeling you may get mixed up here, the FIRST would be argv[0] which ofcourse is the name of the application, once you set your registry then argv[1] will be equal to the text file that called it.

Chris

Freaky_Chris 299 Master Poster

Btw, atoi() will convert it to a number, this may prove helpful for you to multiply your numbers. It will also convert it back to a char from a number.

Chris

Freaky_Chris 299 Master Poster

I'm not sure if i understood you but i think you are after something like this, windows only all i could find

http://www.rutherfurd.net/python/sendkeys/

Freaky_Chris 299 Master Poster

I still have a problem... everytime i close cmd i always need to type

set PATH=%PATH;bin location

before i can use the g++ command.

Is there a way that I can directly use the g++ command after launching cmd?

Yes follow these steps sorry if you already know, i'm going to assume your on XP


1) Right click my computer
2) Select Properties
3) Advanced Tab
5) Environment Variables
6) Under system variables find "Path"
7) Click edit and append with a semicolon separator the new location

And your done, hope that helps

Chris

Freaky_Chris 299 Master Poster

So you change the default program from notepad or whatever to your program, ofcourse this is all done in the registry. Which if you have a look through you will find that the extention .txt will trigger myapp.exe you can append a paramater on the end of that which represents the file name.

Chris

Freaky_Chris 299 Master Poster

I trust you have installed all of the required libraries etc

And set up all global varialbles.

once all is set up i believe this should work

g++.exe "C:\file.cpp" -o "C:\File.cpp" -I"Include directory"  -I"another include directory and so on"  -L"libraries"

and to run it

start C:\file.exe
Freaky_Chris 299 Master Poster

hehe thanks, was eating my dinner a bit distracted :P

Freaky_Chris 299 Master Poster

It has already been pointed out to you. if (genArray[i] == "ACG") This will not work, your are comparing a char* with a string. As it has already been pointed out.

I'll just restate the fact you need to check character by character

if (genArray[i] == "A"){
  if (genArray[i+1] == "C"){
    if (genArray[i+2] == "G"){
       std::cout << "Found 1!"
    }
  }
}

very simple way

Freaky_Chris 299 Master Poster

Scan your pc using any half decent spyware removal tool / ad-ware removal tool. If it cannot fix it, then it will more than likely tell you which file it is embedded in so just find it and delete it yourself. BTW post in the correct forum please.

Freaky_Chris 299 Master Poster

if you have downloaded and install all the latest drivers for your correct model number it should work fine...

Freaky_Chris 299 Master Poster

You will need to install all the drivers listed on the manufacturers site

Freaky_Chris 299 Master Poster

You are still trying to print out the value of a before you have retrieved its value from the user via scanf()

Freaky_Chris 299 Master Poster

I'm wondering if you paid attention to arkM now since the very first sentence that he said solves your problem and it compilies, although not the best code every as pointed out.

Chris

Freaky_Chris 299 Master Poster

Well my only suggestion is that it is in character.h, since that is where it appears those classes and functions are defined

Freaky_Chris 299 Master Poster

nvm shush i should think

perhaps its in your other file

Freaky_Chris 299 Master Poster

Perhaps this will help

Freaky_Chris 299 Master Poster

Tkinter is the easier, and has one big advantage; its standard.

However i personally find hat wxPython is better although slightly harder to learn.

Chris

Freaky_Chris 299 Master Poster
m= start[0]*60+start[1]
n= finish[0]*60+finish[1]

here there is a problem, start[0] refers to the first character in the string start. so from your exmaple of 14, 12 start[0] would be 1. and start[1] would be 4. Also you would need to convert those to intergers before multiplying by 60 otherwise you will end up with

111111111111....60 of them.

Hope you can see where you are going wrong.

Chris

Freaky_Chris 299 Master Poster
for word in list:
            print word+",",

or did i just miss what you asked?

Freaky_Chris 299 Master Poster
def dela(c):
     sum=0
     pile = []
     while sum < c:
         b = random.randrange (1, 10 - sum + 1)
         pile.append(b)
         sum += 1
     print pile,sum
     return sum, pile
def ordna(x):
    b = 0
    y = []
    for num in x:
        new_num = num-1
        if new_num<0:
            del new_num
        else:
            y.append(new_num)
            b+=1
    y.append (b)
    y.sort()
    y.reverse ()
    print " ".join(map(str,y))
    return y
c=lasin ()
pile=dela(c)
ordna(pile)

This is fine you can use both a and b that are returned, when you return them in the way you have the result is a tuple.

just means that you have to access each bit indervidual.

so to use the list of numbers that is returned in this case you would have to put

ordna(pile[1])

If you print them you will see that you can access both

print pile[0]
print pile[1]

Notice that the first line will print the interger that you returned and the second line will print the list of numbers you returned.

Chris

Freaky_Chris 299 Master Poster

First print --> [2, 5, 7, 7] 4
Second print --> (4, [2, 5, 7, 7])

the first print is showing 2 different objects.
The second print is showing 1 object.

Read about lists & tuples, embedding in particular, this may help you understand

Chris

Freaky_Chris 299 Master Poster

It works perfectly, you just need to read about unicode(UTF-8) encoding and other data encoding. By default you are using ascii....which arabic characters do not fall under.

Chris

Freaky_Chris 299 Master Poster

Indeed, after the def statement everything indented is included in the function for example.

def myfunc():
   #in function
   #still in function
   #when in a function you can use normal indenting
   #as long as you have the first indent as well
#this has ended the function definition since it is not indented.

Hope that helps

Chris

Freaky_Chris 299 Master Poster

what you saying is you want to use the same bit of code over and over?
sorry if this is not what you are asking
if so then you use a function

def myFunction(param1, param2):
   print param1
   print int(param2)**3

myFunction("Hello", 2)
myFunction("Joe", 3)

Hope this helps


Chris

Freaky_Chris 299 Master Poster

mywxpythonscript.pyw

this will then run with pythonw.exe which doesn't run the commandline window

Chris

Freaky_Chris 299 Master Poster

Simple read the use file.readlines() on both files to give you 2 arrays

so something like this

f1 = open("file1.txt", "r")
f2 = open("file2.txt", "r")

fileOne = f1.readlines()
fileTwo = f2.readlines()
f1.close()
f2.close()
outFile = open("results.txt", "w")
x = 0
for i in fileOne:
   if i != fileTwo[x]:
      outFile.write(i+" <> "+fileTwo[x])
   x += 1

outFile.close()

something along those lines

Chris

Freaky_Chris 299 Master Poster

One way is to raise you own exception and then catch it with a break.

class myException(Exception): pass
w = input("Enter width")
h = input("Enter height")

for x in range(0,w):
    for y in range(0,h):
        print x,y
        if (raw_input("Stop? y/n") == "y"):
            raise myException
    except myException:
       break

any help?

Chris

Freaky_Chris 299 Master Poster

Hope it works for you, like i say we can always change it.

Congratulations, with the new born.

Chris

Freaky_Chris 299 Master Poster

lol thanks for pointing that out, i've updated it to avoid confusion. In actually fact although it is bad, in that example it will work fine. The only time you will have a problem with that is if you do something liek "C:\", which will be obvious when you do it that it is an error.

Chris

Freaky_Chris 299 Master Poster
import os
folderA = []
for path, dirs, files in os.walk("C:\\Folder A"):
   for f in files:
      folderA.append(f)

i = 0

for path, dirs, files in os.walk("C:\\Folder B"):
   for f in files:
      os.rename(f, folderA[i])
      i += 1

Something like that should work nicely for you. Not tested so if it doesn't work just post back xD

Chris