1,105,225 Community Members

Latest Posts in Software Development

Member Avatar
Pyler
Junior Poster in Training
51 posts since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I'm implementing a generi method that's supposed to traverse a binary tree in PostOrder but when I attempt to use it, the Iterator doesn't work as It should when I attempt to use ot on a Binary Tree, can anyone spot my mistake in the code? Thanks.

The method makes use of a generic POIterator class which implements a generic Iterator<T>

here's th POIterator class

public class POIterator<T> implements Iterator<T>{
Deque<BNode<E>>someStack = new LinkedList<BNNode<E>>();
BNode<E> position;

public T next(){
    position = position.pop();
    if(!position.hasLeftNode())
        return position.getInfo();
        else{
            position = position.getLeftNode();
            somestack.push(position);}
        next();//recurisive call
        position = position.pop();
        if(!position.hasRightNode())
            next();//recursive call 
}//end of next() method;

I have a getPOIterator method in some other class.
When I run tests to check my POIterator method, it doesn't work well/asits supposed to.
Can anyone find anything wrong wuth my POIterator code?

Member Avatar
Gurjot_1
Newbie Poster
3 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks! Okay so after the while loop add the instream infile >> d[i].cost;

Member Avatar
deceptikon
Eternally Awesome
4,687 posts since Jan 2012
Reputation Points: 1,341 [?]
Q&As Helped to Solve: 686 [?]
Skill Endorsements: 104 [?]
Administrator
Featured
 
0
 

Your pointer doesn't point anywhere meaningful. Allocate some memory to it first. Also, there's a different getline for C-style strings that's a member function of cin.

Member Avatar
pritaeas
mod_pritaeas
11,309 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 
Member Avatar
phorce
Veteran Poster
1,014 posts since Jul 2011
Reputation Points: 105 [?]
Q&As Helped to Solve: 133 [?]
Skill Endorsements: 29 [?]
Featured
 
0
 

Please do not create a new topic with the same question; this can be classed as spam and your question will be deleted.

What you are doing here is using the same array, which, in tern most likely segment and thus time out.

Try, something like the following:

  for(int n = 0; n < num_samples; n++) //where n is the step |start of for loop
  {
     int fr = 523;          //Frequency A  
     data[n] = amp*sin(2*pi*fr*n/fs);  
     cout << n << "\t" << data <<"\n"; 

     int fre = 587;       //Frequency B  
     data[n] = amp*sin(2*pi*fre*n/fs);  
     cout << n << "\t" << data <<"\n"; 
   }

But, even this would not work. Why won't it work? Simply because your structure has to be like this:

|one tone| -> -> -> |two tone|

If you take a look at the code sample that I give you, using vectors, I created 2 vectors which stored the two tones, then, having a separate vector which concatenated the data series. This is what you need to use.

My best advice would be to sit down and really think about this problem; what you're trying to do in C++ is not for the average user, you should have atleast some experience in arrays, and, data structure before you begin tackling this problem.

P.S. num_samples will need to be double the size of the array that you have.. If size is currently 512, it would be 512*512

Member Avatar
Jake_4
Newbie Poster
6 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello, I am trying to create a tone, then another tone using this code. It currently only plays one of them. Is there something missing or am i going about this wrong?

  for(int n = 0; n < num_samples; n++) //where n is the step |start of for loop
    {
    int fr = 523;          //Frequency A  
    data[n] = amp*sin(2*pi*fr*n/fs);  
    cout << n << "\t" << data <<"\n"; 
    }     // | end of for loop

    for(int n = 0; n < num_samples; n++) //where n is the step |start of for loop
    {
    int fre = 587;       //Frequency B  
    data[n] = amp*sin(2*pi*fre*n/fs);  
    cout << n << "\t" << data <<"\n"; 
    }     // | end of for loop


    write_wav_file(data, num_samples, fs, fp);
Member Avatar
Ancient Dragon
Achieved Level 70
27,610 posts since Aug 2005
Reputation Points: 5,232 [?]
Q&As Helped to Solve: 3,033 [?]
Skill Endorsements: 115 [?]
Team Colleague
Featured
Sponsor
 
0
 

Maybe you need admin permissions to do that. Move the pdf file somewhere else such as c:\temp and see if the problem goes away.

Member Avatar
rstringer
Newbie Poster
1 post since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello All,

I am working on an Access 2010 application.
I would like to click on a command button and open a Adobe PDF document.
The code for the On-Click event is:

Set shell = CreateObject("WScript.Shell")
shell.Run """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\acrord32.exe"" SourceFile"

When the Shell.Run line executes, Acrobat returns an error saying Access Denied.
I have RW access to the folder and can double-click on any PDF file there and open it successfully.

Can anyone explain why I can't open it from within my application?

Thanks in advance,
Rich

Member Avatar
phorce
Veteran Poster
1,014 posts since Jul 2011
Reputation Points: 105 [?]
Q&As Helped to Solve: 133 [?]
Skill Endorsements: 29 [?]
Featured
 
0
 

So, as I said in my first post. If you increase the total number of n values, then, you would therefore increase the total size of the audio file.. n < 256 > 1024 That being said. You could (as a test) have two different loops that write to two different arrays and then concatenate these two arrays before writing them to the .wav file.

Let me know how you get on

Member Avatar
Jake_4
Newbie Poster
6 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thank you for that it is interesting; though I understand the frequencies, i just put 500 as an easy number. My problem is when i open up the wav file, it plays a 1 second tone Beeeeeeeeeep, i want it to go beeeeeeeeeep, booooooooooooop. would a second loop be the answer? if so how would i format the code?

Member Avatar
phorce
Veteran Poster
1,014 posts since Jul 2011
Reputation Points: 105 [?]
Q&As Helped to Solve: 133 [?]
Skill Endorsements: 29 [?]
Featured
 
0
 
Member Avatar
Learner010
Posting Whiz in Training
245 posts since Jun 2013
Reputation Points: 69 [?]
Q&As Helped to Solve: 15 [?]
Skill Endorsements: 12 [?]
 
0
 

i've declared pointer to char for getting input but i'm unable to get input using getline in this case :

char* str;
cout<<"enter string";
getline(cin,str);

its not working however i solved the issue using the following code(but i want that why the above code is not working)

string str;
cout<<"enter string";
getline(cin,str);

i want to know about this (char*) for getting input.

Member Avatar
slate
Posting Whiz
375 posts since Jun 2008
Reputation Points: 163 [?]
Q&As Helped to Solve: 106 [?]
Skill Endorsements: 10 [?]
 
0
 
* We create a list of one character strings, which are the button labels and numbers or operations at the same time. 
line 6-11
* We start a loop on button label elements. We interpret an index of a button label element as a row, column index. row= index//4+1 column=index%4
line 13-15, line 19-21, 
* In this loop for each element **begin**
* We create a button, with the following attributes 
    * the actual label element as text 
line 17 text=buttons
    * a function call with the actual label element as a parameter (function not explained here)
line 16 and line 17 'command=cmd '
    * we set the button's grid, to place the button to row and column
line 17 '.grid(row=r, column=c)'
* In this loop for each element **end**
* We create an entry widget  on the first (0th) row and make it span 4 column.
line 22-23
Member Avatar
Ermina
Newbie Poster
11 posts since Aug 2013
Reputation Points: -6 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 1 [?]
 
0
 

done with this question :)

Member Avatar
Doogledude123
Junior Poster
150 posts since Jun 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

Would you mind being one?

Member Avatar
Jake_4
Newbie Poster
6 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

all of that has been declared in the full code. When i say tune, i mean small scale, say the c scale for example. i have the first c note with that loop, the next step is D playing straight after. Any ideas?

Member Avatar
JamesCherrill
... trying to help
10,376 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,750 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

romdan doesn't seem to have contributed to his homework discussion at all, so it would be a pity to post a complete solution for him to copy and get the credit for.
Equally it would be a pity to deprive you of some constructive feedback. Maybe PM it to a few suitable candidates and ask for feedback?

Member Avatar
Doogledude123
Junior Poster
150 posts since Jun 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

I programmed this myself as a challenge, could someone check it over to see if all the requirements were met?
Should I post it in a new Thread and link it here?

Member Avatar
Peter_18
Newbie Poster
1 post since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
#the following will copy any dll files in my_file.txt from
#C:\Windows\Sytem32 to C:\Tools
import os
import shutil

sourcedir = "C:\\Windows\\System32"

source = os.listdir(sourcedir)

destination = "C:\\Tools"  

dllmatch = open("my_file.txt", "r")    # may need full path here

matchf = dllmatch.readlines()

for i in range(0,len(matchf)):
    if matchf[i][-1] == "\n":
        matchf[i] = matchf[i][:-1]    # :-1 to strip off \n

for files in source:
    if files in matchf:
        if os.path.splitext(files)[1] == ".dll":
            shutil.copy(os.path.join(sourcedir,files),destination)
Member Avatar
jnneson
Newbie Poster
4 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

@Schol-R-LEA, Thank so much for your time, well, I would say I have once read a book on html, but that is about two year ago-I still have the ideal do.... scheme- I am just hearing about it for the first time, I will try and get the book online and read it, I have heard about python and Ruby, I will try to sit up and lay my hand on it.... thank so much, I will first the first three first and see how far I can go with it... Thank again,

Software Development Tag Cloud