tux4life 2,072 Postaholic

i'm using windows xp and dev c++as compiler

is there something like dreamweaver or something for wxwidget inwhich we can go by design mode

Ooooh, you're using Dev-C++, then I've good news for you: there's a "special" edition of Dev-C++ called wxDev-C++ which has a built-in form designer, wxDev-C++ is freely downloadable here:
http://wxdsgn.sourceforge.net/

A very good and useful free ebook about wxDev-C++ is available here:
http://wxdevcpp-book.sourceforge.net/

(If I'm not wrong it's even installed automatically as a part of the wxDev-C++ installation)

So I suggest you to remove Dev-C++ and install wxDev-C++ instead, it does exactly have the same features as a normal Dev-C++, the only difference is that it's more suited for wxWidgets development, meaning that it has a built-in form designer for example.

tux4life 2,072 Postaholic

Dear csurfer, I appreciate for your help,it works now. By the way, how can I do it with "call by reference" method? Some friends claim that "call by reference" is better. Do you have any suggestion about "call by reference" ? What is the advantage of "call by reference" ?
Thanks

With 'better' they probably mean that the data is quicker available to the function when passed by reference, this is because not all the data is copied into the function parameter, but instead of that just a reference to that data is given as an argument to that function, which means that your program doesn't lose time to copy the whole variable's contents.

In this case there's no real performance difference because the array name is converted to a constant pointer to the first element of itself, when you pass it to the function.
(The array's contents aren't copied, just a constant pointer to the first element of the array is passed as an argument).

Resume:
pass by value: the whole variable is copied.
pass by reference: the variable is not copied, instead a reference to that variable is passed.

tux4life 2,072 Postaholic

It's better to wrap code tags in noparse tags to avoid putting spaces here and there just to make it look like a code tag :P

tux4life 2,072 Postaholic

the parameter inside the square brackets when initializing an array represents the LENGTH of an array, not the highest index.

Well, you can get the upper boundary of the array by subtracting one from LENGTH.

tux4life 2,072 Postaholic

Any one can please say what do we mean by a histogram??

STFW: Look here.

tux4life 2,072 Postaholic

Just a remark on your code, as I see you're using system("ERASE [I]file[/I]"); in your code if you want to erase a file from your harddisk.
I can suggest you a better, more portable and more efficient way:
http://www.cplusplus.com/reference/clibrary/cstdio/remove/

:)

tux4life 2,072 Postaholic

Thanks salem.But i really didn't get your meaning?
Good Luck.

Well, he meant that the OP (= Original Poster = the person who started this thread) is probably never going to come back again.

tux4life 2,072 Postaholic

Dear adarshcu,
Now i got your point.thanks.
1)char *abc="xyz";
2)char abc[]="xyz";
3)char *abc;
abc="xyz"
4)char *abc;
abc=(char*)malloc(100);
strcpy(abc,xyz);

Thanks,
DP

Here 1,2 and 3 are read only and 4 is writable. ryt??

1) read only
2) writeable

3) wrong, you only create a pointer of type char, this can't hold a string.
BTW, if you had written it like this:

/* wrong */
char abc[5];
abc = "xyz";

/* right */
char abc[5];
strcpy(abc, "xyz");

Then it was still wrong because you have to use strcpy.
This is writeable, because this pointer is not allowed to point to constant variables within your program.
If you've a pointer, you'll first need to assign some memory to it if you want to store a string.
Note: You should take care that this pointer doesn't modify memory that doesn't belong to the program, or your program will die.

4) writeable
I assume you meant: strcpy(abc, "xyz");

tux4life 2,072 Postaholic

1) I thought that 'bryangarcia' did not get the line
so, i helped him. It would have be a pity if the thread had dragged on just because the obvious possibility was not explored.
2)
I am curious as to know as to how you would have made him learn to read an user's input into a variable.

1) Yes you helped him, but in what a way?
Many people here on Daniweb are great programmers, but they don't give away free code, they rather want to guide the OP through the process on how to achieve something so he can do it himself next time.
2) Well, I'll do my very best to explain it to you, one non-possible option is giving you free code, because we're arguing about that.

Let's start with the OP's question:

what does this mean:
read value of the integer variable first_int from the user's input?
i dont know what's the proper c statement for this... i'm trying my code but there's always an error...

He asked: What does this mean?
And: i dont know what's the proper c statement for this... i'm trying my code but there's always an error...
He explicitly tells us that he has tried it, not bad that he tells us, it's very very good that he tells us.
So a logical question from Ancient Dragon was: Could you show us your code?
If we had seen …

jephthah commented: you're right... but there does come a point, where we (the so-called 'experts') have to give a line or two of code just to keep things moving. merely demonstrating correct use of "scanf" is not "doing his homework" +13
tux4life 2,072 Postaholic

> * If the user wanted to stop the 30 day time period, all he would do is pause or reverse the system clock.
Haha, it's becoming difficult for the OP now :)
Well, what he could do to avoid this is implement his own software timer.
Generally software copy protections are very hard to implement.
You can make it as good as you can, but probably there will always be a way around it.

tux4life 2,072 Postaholic

This is not a solution to your question, I only want to show you how your code would look like in more decent C++, so I basically just changed your code.

#include <iostream>
#include <fstream>
#include <string>
[B]#include <cstdlib>[/B] // #include <stdlib.h>

using namespace std;
[B]const int[/B] MAX_LINES [B]=[/B] 250 // #define MAX_LINES 250
[B]const int[/B] MAX_IN_LINE [B]=[/B] 500 // #define MAX_IN_LINE 500

int main() {
  //open our file
  ifstream myfile ("test1.txt");
  //initialize our array's
  float myarray[MAX_LINES][MAX_IN_LINE];
  //used for knowing how many numbers are stored in each array
  float totalargs[MAX_LINES];
  //rest of variables
  string line,tempnum;
  int end=0;
  int firstarg=0,secondarg=0;
  

  //set all of our arrays to be zero'd out
  memset(myarray,0,MAX_LINES*MAX_IN_LINE);
  memset(totalargs,0,MAX_LINES);

  //make sure file is opened
  if (myfile.is_open()) {
	

	while([B]getline(myfile,line)[/B]) { // !myfile.eof()
	  //if there is a , in the line we have gotten
	  while((end=line.find(',',0))!=string::npos) {
		//get the number before the ,
		tempnum=line.substr(0,end);
		myarray[firstarg][secondarg]=atof(tempnum.c_str());
		secondarg++;
		//erase the part of the line we have gotten
		line.erase(0,end+1);
	  }
	  //we will have an extra number at the end after that loop
	  //this gets that last number
	  tempnum=line.substr(0,line.length());
	  myarray[firstarg][secondarg]=atof(tempnum.c_str());
	  //set the number of args to our array
	  totalargs[firstarg]=secondarg;
	  firstarg++;
	  //reset arg.
	  secondarg=0;
	}
  } else {
	cout << "cannot open";
  }

  //this is extra, but it just shows you your variables and that
  //they really do have numbers in them.
  //cout << "num: " << num << endl;
  for (int x=0;x<firstarg;x++) {
	cout << "Array " << x+1 << ": " << myarray[x][0];
	for (int y=1;y<=totalargs[x];y++) {
	  cout << "," << myarray[x][y];
	}
	cout …
kvprajapati commented: You are always right. +7
tux4life 2,072 Postaholic
tux4life 2,072 Postaholic

i'm a bachelor student doinmg b.e in computer and as my project i've decided to make an banking application using wx widget and i'm really frustrated tring to figure it out .Being new to it i need some help

What OS are you on?
What IDE/compiler are you using?

tux4life 2,072 Postaholic

To the OP:
>Thanks for your comment but i hope to prove you wrong
I wouldn't be happier if you could prove me wrong :)

BTW, another question: What are you going to do when the user takes an image of his pc's harddisk, after the software is successfully activated?
In that case he could just always restore the image (the annoying service is removed then).
Do you also want to cover this?
If yes, then you shouldn't maybe permanently remove the service, but built-in some kind of time delay, and after that the delay is expired, ask the user to re-activate.

>software x is just an example.. as for this case i'm trying out on a third party software.
Then your software is probably only going to work on one specific software package, because every commercial software is different, and every commercial software uses different techniques to store the license key.

tux4life 2,072 Postaholic

Hi AD,

The function returns the buffer in its body, so it's still in the scope
and its value still available, isn't it?

Thanks,
VM

In Ancient Dragon's code it's correct because in his code a pointer to a function argument is returned which means that the memory for that argument was allocated outside that function.
So when the function returns, the memory is still intact for the buffer because you defined the buffer somewhere outside the function's body.
As a result, you can access the upper-cased string directly by using the name of the variable you used as buffer in you program, or via the pointer the function returns to buffer.

In general you should remember the following: your function may return a pointer to a variable which it has received as an argument, but when you want your function return a pointer to a variable which was defined in the function's body itself, you should use dynamic memory allocation to ensure the memory still exists, when the function has returned.
(= to ensure the pointer is pointing to valid memory, valid memory which still belongs to your program)

If you wouldn't do it, the function would return a pointer to for example a local variable which' memory is de-allocated when the function returns.
In fact you can do this (returning a pointer to a local variable defined inside the function's body), but it can be dangerous, because the pointer your …

tux4life 2,072 Postaholic

AD: *t = _totoupper(*s); I don't know that function, please tell me about it :P

Ancient Dragon commented: LOL :) +36
tux4life 2,072 Postaholic

Thank you for your reply.
To avoid that problem should I remove 'static'
or other way to handle such situation, could you
please suggest?

Ancient Dragon has already pointed out a possible solution for this problem:

A better design is to have the calling function pass in a buffer for the destination string.

tux4life 2,072 Postaholic

>That's a common problem with several standard C library functions
Yes, maybe, but I don't see any good reason on why to write a program which contains this common problem again.
(unless it's an assignment and his instructor explicitly asks him to do so).

tux4life 2,072 Postaholic

This function won't work correctly when you convert multiple strings to their uppercase equivalents.
Yes, you return a pointer, but to something in static memory.
When you for example let your function uppercase "hello", your function will return a pointer to "HELLO", okay you save the memory address, then you call the function with another string, this time: "world", now your function will overwrite the previous existing value by "WORLD", and then return a pointer to it, but the first pointer now also points to the same memory, so we have two pointers pointing to the string "WORLD" now.

tux4life 2,072 Postaholic

>I'm quite the newbie in programming...
>Any advice, tips or issues/concerns i should be aware of based on your experience?
So, you told you're newbie, right?
In that case I don't believe that this project will succeed.

tux4life 2,072 Postaholic

Forget it Dream2code, the OP ran away just after posting it, when asked to use the code tags.

And I did my best to politely ask him :'(

Salem commented: You sure did :) +36
tux4life 2,072 Postaholic

If you're on Windows, you could maybe store the password in the registry.
Edit::
BTW, if I remember good, then FileZilla standard stores the passwords in an xml file.
(FileZilla is written in C++, so you could maybe get your hands on the freely downloadable source code?)

tux4life 2,072 Postaholic

To the OP: in case you're copying the whole thing (look at Sky Diploma's post, code mentioned in the link), then don't forget to change void main() to int main() :P

And:

#include <iostream.h>
#include <iomanip.h>
#include <string.h>

to:

#include <iostream>
#include <iomanip>
#include <cstring>

:P

tux4life 2,072 Postaholic

Sorry I misunderstood you.

>can we do it using C?
Using standard C: no.
Using the OS's API: yes.

>i mean to say a function which i can call in between inside a program to check memory usage.
What exactly must this function check then?
Only memory occupied within the program, or also memory occupied by other programs running?

tux4life 2,072 Postaholic

>How to check memory usage by a program by writeing a C program.
A profiler is used for such purposes.

>When the program terminates and we didnot free it what happens exactly?
Most OSes (this means: not all!) clean up all the memory assigned to a program when the program shuts down, but it's dangerous to rely upon this when writing software.

tux4life 2,072 Postaholic

An array of 10 int pointers - same as above.

int(*r[10]);
cout << "\nSize of : " << sizeof(r); // 40 bytes

To the OP:
Please note that if the code looked like:

double(*r[10]); // <-- change made here
cout << "\nSize of : " << sizeof(r); // 40 bytes

would give the same output.
(This is because we're talking about pointers, and as you know: pointers hold memory addresses)

Note:: This post (and adatapost's post) assumed that integers are 4 bytes, but this can differ on your implementation.

tux4life 2,072 Postaholic

>but cannot copy the .cap file and the .inf files as they are lakhs in number.

Whoops! Sorry, you told that it was 1.5GB
Well, could you try your program with another compiler then?
(for example you could go and get the Code::Blocks IDE)

tux4life 2,072 Postaholic

Salem & japhthah btoh of u guyz r nt here to mprove ma englisg bt to solve r problems ,i don't think so dat u guyz knw d answer of ma question dats y u guys chng d topic to improve English ......LoLz u guyz r really sick n noob too....so enjoy ur brainless mind and creativity :P

Aah, another guy who's wasting his time on online games like Runescape and World of Warcraft....
Better get a life, learn properly English, and then we can come back on your problem.
And NO, your stupid chatroom speak is NOT cool, in case you were thinking that.

Check this:
http://www.daniweb.com/forums/faq.php?faq=daniweb_policies

You offended the Keep it clean rule.

And no, we're not here to improve your English, you'll have to do that yourself.
BTW, you've written a beautiful post which wonderfully applies to yourself :P

To the OP: I suggest you to not waste your time here anymore, you're the smartest here eh not, and we're all brainless? You're maybe right, but then it was not that smart of you to become member of a forum which only has brainless minds as you tell.

tux4life 2,072 Postaholic

yes i mean to say just that..
even i fail to understand as to howcan it happen?

I really have no idea why this could happen, maybe a memory leak or something?
Anyway, could you post down your code, together with the .cap files you were using before you got this problem?
(Also the executable please, but zip it up all first!)

How did you compile your .exe, in debug or in release mode?

What compiler are you using?
Edit:: After doing a forum search, I could figure out that you are using Dev-C++, is this still correct?
If yes, then my advice would be to get a decent compiler, the newest Dev-C++ comes with MinGW 3.4.2, the current MinGW release is already: 4.4.0 (watch the version number!)

If your code works fine with other Daniweb members, then probably your compiler installation is broken or something, you could try reinstalling Dev-C++ if you want to continue using it.

tux4life 2,072 Postaholic

So my program dies because I try to fiddle with the const pointer? Shouldn't the compiler be reporting that?

No, let's revise: your pointer points to a string constant (remember it's a constant = read-only), up until here there's nothing wrong, but further in your program there's an instruction which tries to modify that string constant, because a constant may not be modified from within the program, your program dies.
But there's nothing wrong with having a pointer to a string constant in your program, you only have to make sure that you only read the data where the pointer points to, and that you don't try to modify it.
So the issue in your program was that you were trying to modify a constant value.

tux4life 2,072 Postaholic

Use exit() function

http://www.cprogramming.com/fod/exit.html

Possible, but if your main function contains your whole program, then I would rather suggest you to use: return [I]exit_code[/I]; instead of the exit() function :)

tux4life 2,072 Postaholic

Why would you want to wrap this if around the while:

if (k > 1 && m < n)
{
  while(k > 1 && m < n)
  {
  
  }
}

As you can see both conditions are the same, so you can leave out this if :)

Edit::
Like this:

while(k > 1 && m < n)
{

}

This is possible because the instructions in the while loop's body will only get executed when the condition is true (in this case the condition is: k > 1 && m < n, so if this condition isn't true at the beginning of the while loop, your program will just skip over all the instructions inside the loop's body, and proceed executing the first statement after the while loop (if there's one))

tux4life 2,072 Postaholic

Why would you need to use a pointer for this programming task?
I think a recursive function will do fine here.
It's only a small range you have to translate, so a recursive function will be the easiest in my opinion :)
Also: use arrays to store the numbers (in their expanded form, like: "one", "two", "three", ... , "ten", "twenty", "forty", etc. ...)

tux4life 2,072 Postaholic

Hey oopg, I would like to strongly advise you to learn how to use the C++ I/O File System.

tux4life 2,072 Postaholic

Tnx for all tips you gave me, now I'll try to write a code.

Agreed till here.

But if anyone has too much time, could write it instead of me ;) :D

I have too much time, but giving you free code is against the philosophy of this forum.
The problem is, when someone writes the code for you, you won't learn from it, and how can you become a (good) programmer if you don't write code yourself?
The time I would spent by writing the code for you, could easily be spent by giving help to other people on this forum, don't you think this is a better idea?

Anyway, when you come across difficulties while writing the code, and you find no way out, the best thing you can do is: post down the code you have so far, explain where you are difficulties with, and be as specific as possible while describing your difficulties.

tux4life 2,072 Postaholic

Hi Anna,
Now at this point forget about the Artificial Intellegence .just make it a 2 player game.

After its completion you can go for the AI.

Thanks,
DP

Yes, that would be a better idea to begin with.
BTW, Dream2Code it's highly preferable to post using code tags:
http://www.daniweb.com/forums/misc-explaincode.html

tux4life 2,072 Postaholic

Create an array which holds the board state.
(don't forget to initialize the board before using it)

1) Write code to display the board (from the array).
(Test whether everything is displayed correctly).

2) Write code to accept user input.

3) Write code which processes the user input, and places his move at the correct place on the game board (= at the correct place in the array).

4) Add the real gameplay:

  • Add rules and artificial intelligence.
  • Add scores to the game.
  • Add some other custom features.

One very important link you can't avoid to have read once is:
http://cboard.cprogramming.com/c-programming/88495-development-process.html

(The most important thing is that you develop one feature at a time, and only move on to the next thing, when everything works correctly)

tux4life 2,072 Postaholic

Hi,
Can someone tell me how to suppress all the warnings g++ produces? Not specific warnings : I know how to do that. I want to not see any warnings at all when I build.

Thanks.

I have to agree with niek_e, since there's really no reason to not want to see the warnings.
Or are you really begging for bugs in your program?
A warning should be taken seriously, because it informs you about potential bugs in your program.
And we don't want that right?
If you find me a good reason, please tell me.
But I'm sure you just can't find one.

IMO you should always compile with all warnings on. (-Wall).

iamthwee commented: nods +21
tux4life 2,072 Postaholic

Windows 7 in europe looks to be crap. No IE, no Media player, no bundled apps, and no Upgrade Edition. Sucks.

I disagree:
To come back on this: I really wouldn't care about this: I never really used wordpad nor paint, even Windows Media Player not.
I really don't need them, maybe the only useful thing what's in windows, and what I use sometimes is the Windows Calculator :P.

But I never use IE (so why would there need to complain about this rubbish?), I use Firefox instead.
I never use Windows Media Player, because I use VLC instead.
I never use wordpad (I've never needed it up until now), but I could for example directly use OpenOffice, instead of that fake Word.

A Windows Defragmenter?? Why is there need for that if I can simply use a better alternative like SmartDefrag?
SmartDefrag for example defragments your drives much faster and it supports defragmenting multiple drives at the same time.
Oh, and that other utility, how is it called again? Damn I forgot the name, it was something to clean up your harddrive, but pretty much useless, anyway, I use CCleaner as a replacement.

I've to admit that Paint can be useful sometimes, but I'm sure there are alternatives to it.

tux4life 2,072 Postaholic

1) Change the headers: #include <string.h> to #include <string> for example

You intended it the good way, but this is wrong.
string.h is not the same as string.
string.h is a header file which contains string functions for character strings (C-style strings), such as strcat or strcpy or ...(link) .
So to convert it the correct way: change #include <string.h> to #include <[B]c[/B]string> .

tux4life 2,072 Postaholic

>You would be better to do the conversion yourself instead of asking others to do it for you for free.
Yes, 100% agreed :)
To the OP: It will only cost you effort.

To the OP:
One thing you should remember for always and for ever is that: you should never (and take this litterally), but never use void main() .
This is fully against the C++ standard.
According to the standard the main() function can only have int as it's return type, in other words: you must use int main() in your code, no way around.

And now practical (in case you didn't understand what I'm saying):
Change [B]void main()[/B] to [B]int main()[/B] :)

That's already a good starting point eh?

tux4life 2,072 Postaholic

Welcome to this forum, tangent03.
Could you please check out this page, and add code tags to your future posts?

Also, don't use void main() , it's evil.
Instead change it to int main() .

Don't use un-standard libraries such as conio.h, certainly not when you're not using any function from it.
(Remove: #include<conio.h> from your code)

>can anyone explain me how dis code is working
Yes, but it's maybe better that you tell us first how you think the code works.

tux4life 2,072 Postaholic

A little addition on:

Array names become pointers

Yes, an array name is a constant pointer to the first element of that array.

tux4life 2,072 Postaholic

What I guess is that the name "my code" is not a very appropriate name for this thread, because the OP probably didn't even write this code himself.
But who knows? Only the OP, right?
But if he just drops down his code on forum, without any comments, then he's just begging for replies like this one.
If he did, then I strongly suggest him to read the following guide, whatever error or bug there is in his code, this will help to prevent nearly any of them: http://cboard.cprogramming.com/c-programming/88495-development-process.html (follow these guidelines when designing/creating/writing a new program).
I also want to suggest the OP to read this: How to ask questions the smart way.

Salem commented: Excellence! +36
tux4life 2,072 Postaholic

Okay, if you've figured it out, then it's better to mark this thread as solved.

But before you do, I want to give my opinion on the use of the following name in your code: I1.
IMO (= In my opinion) you shouldn't use names like this, I only get frustrated by seeing such one, the I and directly after it a 1, they don't seem to be good friends of each other.

But if you've no problems with this name, then you just do what you want.
I only wanted to let you know, so please feel free if you want to ignore my advice if you don't care about it.

tux4life 2,072 Postaholic

>but I just haven't found a way to search and replace successfully
Create a new file, write the changed contents to it, and delete the old file.

tux4life 2,072 Postaholic

P.S the new paitn and wordpad are good, i like how they use the office-2007 style ribbon UI

Yes, I find the new design much more likeable :)
But, are they adding new features as well ? (I mean: adding new features to paint and wordpad).

tux4life 2,072 Postaholic

With an uppercase on window compilers.

If you're going to send him on the windows.h route, perhaps this might be of relevance: http://msdn.microsoft.com/en-us/library/ms646293(VS.85).aspx

Well, he said he used a Windows compiler, so windows.h is available.
Also: he just wanted to run a modified example of AD's code, I just said him how to fix his code.
Probably because he started talking about getch() and kbhit() , AD has proposed him a code example using those functions instead of using GetAsyncKeyState, but this function will do fine as well :)

>With an uppercase on window compilers.
Yes, I forgot to specify that, on *nix systems it is written in lowercase.

tux4life 2,072 Postaholic

>As you told i tried your logic.. see your edited program... it shows one error
You have to write sleep() as [B]S[/B]leep() (it's written with an uppercase 'S').
And you'll have to add the following include directive at the top of your program as well: #include <windows.h> .

>And I am using Microsoft Visual C++ 6.0
Get a decent compiler.

tux4life 2,072 Postaholic

>if anyone have it please send me the link.
I don't have it, but I can give you a link to an online store, where you can legally buy it.

You cannot get commercial software legally in their full flavor.
(promotional actions are not taken into account here)

What you're thinking is that when someone who previously bought that software, and who does give you a link to a download location (probably with a beautiful license together), you automatically can use that software legally as well, but this is completely wrong.

>THANK YOU
No problem, I wrote this post with pleasure :)