jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Awesome. I hope the change will take. Well, I didn't do too much for you but I'm glad it all worked out.
Definitely post back with further questions.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Indeed it seem to run fine. Runs with the 333 elements too. It's gotta be something else (obviously). Well, at least we learned your input file is not coming in the way it should...
Do you have any strange compiler settings on? Running an old compiler? In the off chance try taking stdio.h out of your includes as you already have cstdio in there.

Failing all else, you could retool that section using fstream methods.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I will tell you one thing that I did suspect before (I don't know if it has any bearing on the situation but you are writing your numeric values into your filename variable):

filename:4_Ticks_LED_Board_0000.bmp refcount:8
filename:272 refcount:201
filename:10 refcount:11
filename:291 refcount:201
filename:10 refcount:12
filename:308 refcount:202
filename:10 refcount:11
filename:280 refcount:217
filename:11 refcount:10
filename:301 refcount:217
filename:10 refcount:11
filename:273 refcount:233
filename:9 refcount:11
filename:289 refcount:233
filename:11 refcount:10
filename:308 refcount:233
filename:10 refcount:12

Maybe that's what you wanted.

Well this

FILE* info;
	char* infoname;
    char* fullname[PATH_MAX];
    char detfilename[PATH_MAX];
    char* filename;
    char detname[] = "det-";


	filename = "kot1.txt";
	//saveDetected = 0;
	infoname = "kot1.txt";

	info = fopen(infoname, "r");

	 if( info != NULL )
	 {

        
        int refcount;

		filename = new char;

		while( !feof( info ) )
		{
			if( fscanf( info, "%s %d", filename, &refcount ) != 2 || refcount <= 0 ){ break;}
			printf("filename:%s refcount:%d\n",filename,refcount);

			int * kot = new int;



		}/*while( !feof( info ) )*/

	}/* if( info != NULL )*/

	fclose(info);

	return 0;

ran without a hitch so I don't know what to tell you. The allocation seems to take place too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I do believe you. I'm just confused as to what it could be. Could you put up a representation of a data file so I can run that snippet on my machine?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How long are the filenames? I'm afraid that I'm not as versed in the stdio.h functions as I used to be, but I still have a strong suspicion that either you're running over the filename array (or not allocating any room for it in the first place having no filename = new char[something]) or you're not leaving enough room for the null terminus.
I was going through the forums to see if I could find a good concrete example that was similar to yours but I didn't turn up much of anything.
So, I apologize as the only thing I'm confident of is that somewhere in that call you are corrupting memory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The one outside of the while above is still "live" @ line 98. What does info contain after you go through the loop once? Since if you "new" it filename's not going to point to anything since you have clobbered what was written in it up above.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
filename = new char;
fscanf( info, "%s %d", filename, &refcount )

I'm not sure that this is working the way you want it to. You redeclare a pointer and then you try to write that to a string. It's confusing things and you might be goofing up the placement of something else.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See my edit above too :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

when I call blob_detect() which uses included .cpp
function which calls .cpp files

I'm a tad confused about what you mean by that. Are you saying that you've included the source for the method in another file in your project?

Also while there is still editing time on your old post, put some code tags around your work
It makes it easier to read and preserves the spacing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If I knew you better I would ask "Is this the dirty baseball cap pulled down to your eyes with the 5 day old scruff look?" I wish more women dug that look.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're going to have to be a bit more specific. What display are you talking about? By "my C language program" do you mean your IDE or some code you have written?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Touché... Well, naturally since you're Johnny Depp, she should be. I meant the music and some tv shows.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Because I happen to know you look nothing like your Avatar, so by extension you very well could be Johnny Depp. The question is, are you prepared as an adult to go undercover in a high school to bust up drug rings and gangs, all the while teaching kids a little something about life. I realize he's had quite a legitimate career since then but I'm stuck in the 80's (the good parts only).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Geez Happygeek, everybody knows the real Johnny Depp was taken and placed into hiding in a secure facility 5 years ago. The stand-in is a convincing replica but if you know your "21 Jumpstreet" you can clearly tell it's a fake. So even if he did "die" rest assured that the real Johnny is alive and well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, that's more doable. To take someone from 0 to 60 in GUI programming would take a tremendous amount of effort on everyone's part. I prefer practicing it in C# anyway where there's code completion. :)

Try some of the spacing yourself with the setw function to control where your columns end up. Of course there's always toss an '\n' here and there for the vertical spacing.

If you're really set on a lot of precise text placement you should look into ncurses (I forgot if you are on PC or *nix). If you're on *nix check and see if it's available for your distro or already installed, for PC check out something like pdcurses. I have no experience with either but it could be a heavy commitment with that too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you're doing C++ you should use fstream, it makes things a lot more intuitive, I think.
If you had no space between level and = you could have something like

ifstream infile("Doc.txt");
while(infile >> tempstring)
{
         //add tempstring to vector or array
         infile >> tempvalue;
         //add tempvalue to it's own array or vector
} //this way you can read in as many lines as you need to
//you'd have to specify the array size before hand or ask the user for 
//how many records

So, if you want to stick with the C style of doing it that's still ok, just wanted to offer the option to you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does the layout of the file look like, for instance are:

inputFile >> appleP;
inputFile >> teaP;
inputFile >> coffeeP;

appleP, teaP and coffeeP all separated by space or a newline? I suspect if they are laid out like the 2 line sample you gave you are trying to read the "goods" into your price variables.

As far as the setprecision goes, I don't see anything explicitly wrong in your code, so I'm not sure.

Put a cin.get() in between lines 53 and 54 so that you get a "pause" effect so you can check out what's on screen. If necessary you can output what you've just input to check it to make sure (I know you think the problem lies in the output but it couldn't hurt).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How far can you get in the process? Can you open up a file? Do you want to read it straight out of the file into one big string to put it in the message box? Try to see how much headway you can make first and then post whatever code you've got. I assume since you want a messagebox that you are familiar with MFC?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the layout of the file? Do you care about periods and commas?

For the assignment we can't use templates or OOP

Is that a roundabout way of saying you can't use std::string?

What approaches have you tried so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Could you take me through a typical input/output (the output I can kinda gather) and elaborate on what the termination factor is?
I think I see what you are trying to do but I'm not sure. It seems to me like you want to take in a bunch of coefficients and store them all in a? Is that true?
Perhaps you're using a different approach, I was getting my info off of here. Apologies for the request for background it's been (well let's not say hehe) too long.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm a bit confused about the multimap aspect. OP has a list of names, there's no real pairings (there just happens to be two names to search for). There are certainly more diverse search options available but I wouldn't change data structures completely unless you know it will save more time than you've already spent.
The search seems to work if there's just one instance of either of the names. The best way to cover multiple instances, I think (someone will probably have a more effective idea) is when you find a name, march backwards from the MiddleBound through the list until you don't find it anymore, then go back to the MiddleBound and go forward until you don't find it anymore (so effectively 2 while loops or 1 if you want to skip over middlebound while you're iterating). You get the idea. See if that works, if it does you're all set but if it doesn't you may have to rework your if statements in the search function and run it one name at a time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I had wondered about that actually. I was writing it in because I thought it was a good habit. I guess that settles it. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I hope you are joking. :) But if you're not, you're going to have to do some homework. What windowing APIs/toolkits do you have access to? You can do Win32 or MFC or Qt or wxWidgets (and there are probably 3-4 more). It's a fairly big commitment and learning curve any way you slice it. So in earnest find out what's available to you -- are you running Visual Studio? You'll need the full version to do MFC but you can do Win32 on the Express...etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, see this post and for an article with lots of examples, see this.

(sorry adatapost, I was already in process when you posted)

kvprajapati commented: You are always helpful +6
chaienbungbu commented: Thanks. After reading your example, I remember that my problem related to "passing by ref". +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

constructArray_2 (a, MAX); You are passing in the value a to your function but there is no a defined in main(). Where is this value supposed to come from?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out what adatapost was trying to show you, or you can even look in your error message:

/usr/include/iso/math_iso.h:63: note: candidates are: double pow(double, double)
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/../../../../include/c++/3.4.3/cmath:361: note:[long double std::pow(long double, int)
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/../../../../include/c++/3.4.3/cmath:357: note: float std::pow(float, int)
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/../../../../include/c++/3.4.3/cmath:353: note: double std::pow(double, int)
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/../../../../include/c++/3.4.3/cmath:349: note: long double std::pow(long double, long double)
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/../../../../include/c++/3.4.3/cmath:345: note: float std::pow(float, float)

Based on these prototypes (i.e., statement defining number and type of parameters as well as return type) you can use it with a double raised to a double or a double raised to an int (or any of the other patterns from the error message). Note that both prototypes I highlighted return a double.

You can cast it to an integer but you will lose any decimal information completely so it could mess things up later on when you go to use it. Probably better to let the precision go through to the next calculation and then you could cast that result.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not 100% on either question, so I'd set out on your own for a bit.

FWIW:
ssize_t is going to have to be one of those things you have to iron out. It's a typedef for sure but it most probably varies from system to system. Look on this page where it gives the Windows header in which it is defined (this information may be out of date).

As far as the second question goes, open up some headers and take a look. I would assume you'd want the function prototype and any standard header files your particular function requires. I've never built a library from scratch on Windows.

I ran into this code on a search out of pure curiosity, I just figured I would share it with you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here is the source. Might not be too much trouble to adapt it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It doesn't seem like you are taking in your coefficients properly. If you are going to do it the way you are, you need to expand the while loop around the statements where you get a new a and term each time.

Otherwise you're using the "a" you read in over and over again in the calculation.

You're also keeping "a" in "num" but never doing anything with it again.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You are correct. It will if you add a constructor to your node struct.

struct node{
     string data;
     node *next; // Pointer to next node
     node(string dat) : data(dat) {}
};

EDIT: fP remember when you kept getting beaten to the punch the other day, well I think it's my turn today. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

He shows it at the beginning :

Thanks fP. Not sure why I missed it, I went over the code like 3 times. :S

@OP I think he's covered it, so see where you can go from there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
private void button1_Click(object sender, EventArgs e)
        {

            //http://dotnetperls.com/filename-datetime
            
            string fName = string.Format("myfile-{0:yyyy-MM-dd_hh-mm-ss-tt}.txt",
            DateTime.Now);

            using (StreamWriter sw = new StreamWriter(fName))
            {
               sw.WriteLine(textBox1.Text);
               sw.Close();

            }
        }

I found the way to get the formatting into one that is acceptable to file names on that site in the comments. Otherwise you can probably play around with the ordering of the time-date information.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Unfortunately you don't show us the add() method itself. Does it make sure that the last pointer is not null? Does it create a head at the beginning if there's not one?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please don't bump your threads so soon, have a bit of patience. I was actually just about to give you: e = d.Base::operator*(1.0); I'm fairly sure that in cases like this you lose the more aesthetic syntax, but I believe that this works.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Very good that you were able to finish all that debugging on your own.
There's one other hitch where after it reads one file it stops. I solved the problem by having a "new" my_file for each trip through the loop (there's probably a way to reset the pointer but I had tried a my_file.seekg(0); which did not work). So, just something to watch out for -- just replace the my_file.open(path.c_str()); with fstream my_file(path.c_str()); on line 87 of your full code listing a few posts back. It's likely there's a more proper method of doing this.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check to see if it's still running somewhere (if it's not in the taskbar, open the task manager and see if it's still there, end the process if it is). Failing that try rebooting. If that still doesn't help you might have to create a new project and incorporate the existing source files.

EDIT: LOL AD had me by 2 seconds or less hehe

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hate to be a "Me too" but me too just now. I had also experienced the 15 second message Salem got a few days ago. I'm going to lie awake tonight staring at the ceiling wondering why me. :D

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
void getFname(string path,string str[], int & position)
{
	string t=(path+"*.txt");
	cout <<"Path "<<t<<endl;
	if((hfile=_findfirst(t.c_str(),&c_file))==-1L)
	{}
			
	else
	{
                position=0;
		//str[0]=path+c_file.name;
		//position++;    [SEE BELOW]
			
				
		do{				
					
			str[position]=path+c_file.name;
			position++;
					
					
			}while(_findnext(hfile,&c_file)==0);

I made a mistake, you need to take out those lines too as it's accomplished in the first pass of the do/while. Otherwise you're doubling your first file.

There's something wrong with the program that it doesn't find the tokens in anything after the first file. Have you run across this?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How do you display your other characters? I would just output the actual 'Q' on the die and add the extra character as if you were adding the next actual letter.

e.g.,

cout <<dice[i][j];
if(dice[i][j] == 'Q')
     cout<<'u';
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm going to be shipping out so wrestle with that a bit more on your own. In my further testing there is some issue with the path as it is coming in from main() (it seems to have extra spaces or an extra \n in there somewhere).

It's coming along. I think you'll be proud of the end result. Happy debugging.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm going to be shipping out so wrestle with that a bit more on your own. In my further testing there is some issue with the path as it is coming in from main() (it seems to have extra spaces or an extra \n in there somewhere).

It's coming along. I think you'll be proud of the end result. Happy debugging.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
bool manipulation1(string path)	
		{	
			fstream  my_file;
			string line;
			char * cstr;
			char	* p;
			char delim[]=" :'.,?><_+{}[]();";
                	string ext=".txt";
			bool found=false;
			string strArray[20]; //keep this to use it 
			
	                      // string* d= get rid of this	
             f.getFname(path,strArray);

                            //now skip all the strArray[i] = D[i] stuff but this time
                           //you'll have the correct filenames

And more importantly you know that everything up until that point is working. Now you can make the similar changes in manipulation2. Then we can make sure that everything's working after that point in that method. Debugging, it's a wonderful thing.

EDIT: Now that I'm looking at it, it might be advantageous to either return or send in as a reference parameter the "position" variable, so you can use that to control your loops.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I was telling you to send in the array (by pointer, I said by reference by mistake) rather than returning a pointer like you did. So declare your array of strings (to store the filenames) in your fileManipulation class rather than in the file class, e.g.,

string fnames[20]; //I'd do more than that if you have big directories
getFname(path,fnames);

-then-
you can access as fnames[0], etc.
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Got part of it:
In your file class

void getFname(string path,string str[]) 
         {           //change to returning an array
		 //by reference, just to make things easier

                     //leave the rest the same
                      //but instead of your while
                   do{				
			str[position]=path+c_file.name;
			position++;
			}while(_findnext(hfile,&c_file)==0);
           //and get rid of the return statement

Your while loop was only executing once after the initial time, I think it needs the prior result as a seed for the next (I'm sure there's more to it than that but I am not really familiar enough with it to say).

So test that on a few directories and try to reintegrate it with your other code.

yahh , it works.

I don't believe that for a second after I spent all that time looking over it for you! (to be polite) It was getting the first and last items of the directory and nothing more.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Something like this will work http://pdcurses.sourceforge.net/ (the header alone won't do you any good without the libraries anyway)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The program only asks the user to input the word which he wants to search in specific directory and folder ,then my program searches all the files in that folder, and check whether the word is found or not.
So its the responsibility of my prog to search for the file names.

Have you tested your File class in isolation, that is does it (by itself) produce a list of files from a given directory?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

whatever input , i give, it says word not found, file not opened!!

See my edit above if it hadn't come through.

My honest opinion, I would cut and paste all that elaborate menu stuff out for the time being.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What's the problem you have been having with it?

In your main() you never explicitly ask for the filename, you just tack the extension onto the folder name.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

you have to mention its return type "void" or "int".

void main is actually incorrect (though your compiler may take it)
See this article.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need to put the return type of the function before its name when you are calling it (definitely need it in the prototype and in the definition though) reverse(s,i); is all you need on that line you have marked.

Also, you should put int in front of main (your compiler might be doing it implicitly but don't rely on that)