siddhant3s 1,429 Practically a Posting Shark

The script on which the login details is to be sent is https://webconnect.bloomfield.org/Zangle/StudentConnect/logincheck.aspx and not https://webconnect.bloomfield.org/Zangle/StudentConnect/ I know this because I opened the HTML source of the page /StudentConnect/ and then looked the action attribute of the <form> tag

siddhant3s 1,429 Practically a Posting Shark

>IF UR PROG NEED SOME INPUT GIVE IT & PRESS ENTER AND USE "getch();"
>(REQUIRES "conio.h") AT THE END OF UR PROG.
Thanks for giving your ancestral trick. I promise I won't tell anyone.

siddhant3s 1,429 Practically a Posting Shark

Oh no please. Not Sams teach X in Y days. I hate it.
Read this : Teach Yourself Programming in Ten Years by Peter Norvig
. An excellent article to reply Sams

tux4life commented: Great link, I'm not a SAMS fan too :) +9
siddhant3s 1,429 Practically a Posting Shark

I am glad I could help you.
Please mark the thread as "Solved" by clicking the "Mark this thread Solved" link. It would be near the bottom of this page.

siddhant3s 1,429 Practically a Posting Shark

>I am writing a very big program and this macro concept is needed to use there.
Macros are evil: either it be a small program or a big one. The risk of complexity increases as the LOC (Line Of COde) increases. If your program is big, there are even more reasons to hate macros.
>Actually I've mensioned earlier what I need to do,it might be possible you
>ignored that but its ok my friend

If you think that you told me, perhaps you need to be more expressive. Here is a very nice article on How to ask question the smart way. You are expected to read this, it will help.
>value of def
there is no value of def. def is a function. The correct phrase would be
"the value returned by def"

>Once I given the value of def,I don't want to give it again through the program.
You can pass the value of m as a argument to the function sub(). This would be perhaps the most nice way to do this.

siddhant3s 1,429 Practically a Posting Shark

>now it's not just shutting down
But where did you wrote the code to shut down the PC? You haven't.
Your coding style is rusted. Have a look at this guide to improve.
Especially read the 2.3 and 2.5 section of this guide.

siddhant3s 1,429 Practically a Posting Shark

>Move file pointer to the end of file using seekg(); use tellg() to get the length of file.
Not likely. While the file is opened in text mode, the seek and tell functions do not necessarily deal in pure byte offsets from the beginning of the file.
Read this FAQ: http://www.c-faq.com/stdio/textvsbinary.html third paragraph

siddhant3s 1,429 Practically a Posting Shark

So, what are your problems. Are we supposed to copy your code into our compilers, compile it and then check for errors. (By the way, I just did all this and found that your program ran smoothly giving no errors).

>So,please any C/C++ expert please help me out from this problem
what problem? your program is working fine

Note: Use of macros are not recommended for C++ programmers. There is no good reason to practice it. Read section 3.1 of this document to know why.
Also note that conio.h is a non-portable file and is thus, not encouraged. Read the section 2.3.2 of the same document.

siddhant3s 1,429 Practically a Posting Shark

I love python for this: I was parsing HTML code just after 2 weeks of learning Python,

siddhant3s 1,429 Practically a Posting Shark

>Open an HTTP connection to your server, then do a "get" to retrieve some
>information.
You may use cURL(if you are using C )cURLpp(if you are using C++) as a library which implements HTTP/GET and HTTP/POST

siddhant3s 1,429 Practically a Posting Shark

cURL is the library which is used to do HTTP/FTP and similar protocols.
There is a decent binding cURLpp for C++ which would be best for what you want.

PS: C++ language as such do not have such functionality.

siddhant3s 1,429 Practically a Posting Shark

You should not be using enum if you intend to do this.
You must know the real objective/point/motive of using enums.
Look at this brilliant page: http://enel.ucalgary.ca/People/Norman/enel315_winter1997/enum_types/

In short, enums are just a way to give symbolic name to the group of logically similar integers.

siddhant3s 1,429 Practically a Posting Shark

Okay. I had enough!
It had been 11 posts in this thread and I cannot belive no one told OP to use code tags.
To the OP, it doesn't mean you shouldn't be knowing about code-tags. You should be posting the code using code-tags. Information about code-tag is posted all over the website :
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used
6) Even on the background of the box you actually typed your message in

Salem commented: Well said!!!! +35
siddhant3s 1,429 Practically a Posting Shark

Why do they use the same words for different things?
I always thought Entropy S:
[tex]dS = \frac{\delta q}{T}[/tex]
and
[tex]S = - k\sum_i P_i \ln P_i \![/tex]

Edit: The second formula is from Statistical Thermodynamics.

iamthwee commented: O! ALMIGHTY! Like ALBERT EINSTIEN, Make Me Bright, So that I am Able to Kill Dark, And Make This World Full Of Light -4
jephthah commented: ehh, okay, here's your points back. but publicly complaining about neg rep is kind of gauche. +11
siddhant3s 1,429 Practically a Posting Shark

>They add unnecessary complexity?
Oh stop kidding......
They are simplifying the program not making it more complex. Your example won't work if you intend to write a function to count the number of words in a given string.

siddhant3s 1,429 Practically a Posting Shark

You are correct in saying that you cannot actually delete a part of file.
So here is what you usually do.
Suppose you want to delete everything from the 57th byte to 64th byte:
--You first copy the first 56th bytes to a temp file
--Then you copy the 65th to last byte to the same temp file.
--You delete the main file
--You rename the temp file to the same name as main file.

siddhant3s 1,429 Practically a Posting Shark

Why not use stringstreams?

#include<iostream>
#include<string>
#include<sstream>
int main()
{
    std::string str;
    getline(std::cin,str);
    std::stringstream sstrm(str);
    int count=0;
    std::string temp;
    while(sstrm>>temp) count++;
    
    std::cout<<count<<std::enl;
}

output:

siddhant3s@Xion:~$ g++ tester.cpp -o tester.exe -ansi -pedantic && ./tester.exe
Let me type something   which 	also contains tabs
8
siddhant3s@Xion:~$

Edit: [siddhant3s wants to question the world why he every time late by few seconds. @Ancient Dragon]

siddhant3s 1,429 Practically a Posting Shark

>Please bear in mind that Daniweb is no remote compiler service or something
What a good idea. I have started to think to write one :-)
Bloody who will support the webhosting services :(

tux4life commented: You are really unbelievable ! First you write an excellent guide, now siddhant is designing a remote compiler service :P +9
WaltP commented: Nice idea, but it already exists... +20
siddhant3s 1,429 Practically a Posting Shark

It is officially clear that the code is best understandable by its author.
About C++:
It is (nearly) a perfect language with majority of imperfect programmers.
Most of high school teach C++ with giving students proper programming background. These student, mis-interpret themselves as C++ programmers and write crap code. And thus they spoil the name of language.
I still feel sorry "Why the hell they decided to teach them C++ first??"

siddhant3s 1,429 Practically a Posting Shark

Okay, as you are here on C++ forum, you would get C++ as the favorite language here.
If you are starting to program, the single most language that you should learn is Python.
I have listed the major power of "Why Python for Beginners" on StackOverflow recently :http://stackoverflow.com/questions/990157/what-is-a-good-programming-language-for-beginners/990246#990246
have a look here and then decide.
C++ is a good language. It will take a long time to master it until you become sufficiently productive. Python will boost your productivity like anything.
Here is a funny cartoon which I like very much :
[img]http://imgs.xkcd.com/comics/python.png[/img]

So, my advice is to drop c++ for now and start with Python.

siddhant3s 1,429 Practically a Posting Shark

Just to clarify what sridhar said, read this http://www.wikihow.com/Convert-from-Decimal-to-Binary
And please learn to use a search engine.

siddhant3s 1,429 Practically a Posting Shark

>why did you change
Answer; I was in a hurry. I wanted to give you the main point about constructors. :)
spare me if you could

siddhant3s 1,429 Practically a Posting Shark

Ball_1 is a vector object. A vector object do not have a .itsposition member.
Try Ball_1.itsPosition
or better: pass Ball Ball_1 as the argument of function Distance rather than std::vector < Ball > Ball_1

siddhant3s 1,429 Practically a Posting Shark

Yes there is: Use constructors. I think you will learn about them a bit later:

struct CandyBar
	{
		string brandName;
		float weight;
		int calories;
		
		//no argument constructor
		CandyBar(){}
		
		//a argumented constructor
		CandyBar(string bn, float w, int cal):
		brandName(bn), weight(w), calories(c) {}
		
	};
	
//in main()
CandyBar* cb= new[3];
cb[0]=CandyBar("snickers",2.2,147);
cb[1]=CandyBar("nickers",4.22,1447);
cb[2]=CandyBar("kers",7.22,447);

//print all of these
siddhant3s 1,429 Practically a Posting Shark

>separated by '\n' or '\r\n', depending on the os
Don't you know that C automatically translate '\n' into the native newline character when files are opened in text mode?
Read http://en.wikipedia.org/wiki/Newline#Newline_in_programming_languages 2nd point.

Hence you never need to bother what is the newline character of underlying implementation, just use '\n' all the way.

siddhant3s 1,429 Practically a Posting Shark

So you have your home-made String class and want it to implicitly convert to C-string(a zero-terminated character array).
You would have to overload the operator char*()
Read http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=24
And always search the web before posting.

chaines51 commented: Thanks for the help! +1
siddhant3s 1,429 Practically a Posting Shark

Did you tried this??

>>>s="No one can be told how good Python is, you have to See it for your self"
>>> for x in s.split():
...     if (x[0].isupper()):
...             print x
... 
No
Python
See
siddhant3s 1,429 Practically a Posting Shark

How are you giving the strings?
If you are giving a complete python program in the string, you do a trick:
Write all the string into a file and execute it with the interpreter by using a execv or system command.

siddhant3s 1,429 Practically a Posting Shark

Oh please. Micro-optimization is not cool. Adhere to the philosophy that "Developers time is far far more important than machine time"
Small optimization won't make significant changes in the execution but will drastically increase your head ache.
I find Salem post to be extremely right in this regard. Very well said.
My advice is : use the one which will save you headache while debugging a month( or perhaps a fortnight) later.


>if it's around 10 minutes, then a few minutes either way won't get them back
>from the coffee break any time sooner.
I can have two cups in those 10 minutes. :)

Salem commented: Yes, a wasted week of every users' time changes the calculation a hell of a lot! +35
siddhant3s 1,429 Practically a Posting Shark

>And yes, I know, sorry that the code is not fully formatted, that is because I wrote it
>before I discovered
At least I don't expect you to format a code which is not yours. I mean it is just enough for you to post unformatted code provide it doesn't cause much harm to the eyes. For larger and complex program, formatting is essential.
>WaltP's excellent code formatting guide
I don't see a point in formatting your code "by hand" although it is a good practice. These days, source code pretty-fier are available which performs very impressive formatting. Astyle is my favorite. Just call the program with your filename as an argument and you are done. ( Using astyle become more easy on windows since you just have to drag and drop on the exe icon.)
>but it will cause the integer variable each time to be implicitly converted to an
>unsigned long
Yes. This is a clear point of not using that trick but I was wondering that if it will cause some portability issue. I am sure of it but cannot find some references.

siddhant3s 1,429 Practically a Posting Shark

1. Write the int isPalindromeHelper(char A[],int n) such that it takes a array of char A of a size n and returns 1 if it is a palindrome and 0 it it is not:
isPalindromeHelper("LOLA",3) should return 1 and
isPalindromeHelper("LOLA",4) should return 0

2.Then wrap this function with isPalindrome(char s[]):
isPalindrome checks if the string entered is palindrome by calling isPalindromeHelper(s, strlen(s) ).

If you have any problem in writing the code, try it first and then post it here if it doesn't work. Note that no one is going to write it for you here. :)

siddhant3s 1,429 Practically a Posting Shark
>>> s="abc123abc"
>>> t= "".join([x for x in s if x.isdigit()]+[x for x in s if not x.isdigit()])
>>> print t
123abcabc
>>>

This was the quickest I got in my mind.

Try not to use regular expression. They are quite slow.

siddhant3s 1,429 Practically a Posting Shark

A function defined inside a class is automatically request the compiler to make it inline:

class foo
{ 
    int f1()
    {
        //the definition
       // This function is inline
    }
    int f2();
}
int foo::f2()
{
  //the definition goes here
  //function is not inline
}

In above example f1 is inline while f2 is not.
In general, a inline function cannot contain loops or switch statements. Hence your compiler is making that warning.

Note that the style of your coding is 15 year old and is deprecated( I call such code as "rusted"). Sky Diploma is right in giving you advice to use a modern compiler ( I bet you would be using something as crappy as Turbo C++).
Please read this and migrate to standard.

siddhant3s 1,429 Practically a Posting Shark

>>Adding UL solved the thing and making j long didnt solve it
Don't add UL, Make the j a unsigned long.
I am sensing adding UL is dangerous. But I have no reference right now. I will find and then post it.
j should be a unsigned long

siddhant3s 1,429 Practically a Posting Shark

>If i use long for j instead of int will it work???
Yes

Edit: Why?
100001*100001=10000200001
So obviously a int cannot hold this number.

Adding UL won't solve the thing
Edit2: I realized that adding UL does solved the problem. I am don't think it is good. You should rather change the type of j to unsigned long

siddhant3s 1,429 Practically a Posting Shark
Sky Diploma commented: Thanks :) +3
siddhant3s 1,429 Practically a Posting Shark

>Better open this specifically in input mode mode as
He is doing fine: he declared the object of ifstream hence it is fine not to mention ios::in

To OP:
a. You coding is what use to be 15 years ago. I think it is time to change. Read this.
If your school forces you to use iostream.h and other deprecated coding style, you can do what they want in school but practice standard coding otherwise.
b. You should be posting the code using code-tags. Information about code-tag is posted all over the website :
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used
6) Even on the background of the box you actually typed your message in
So don't tell us that "you didn't knew about code-tags"

c. Please read How to ask questions the smart way and learn that it is yourproblem that you have to submit the assignment till 18th, not ours.

Salem commented: Lots of good points +35
siddhant3s 1,429 Practically a Posting Shark

He said he want a open source compiler.
First of all, Congratulations for choosing Open Source.
G++ is accepted as the most widely used open source compiler. You can use it on M$ Windows too.
MinGW is just a port of G++ for M$ windows. Both are nearly same thing.
You can use CodeBlocks as your IDE. Codeblocks is also free and it support g++/MinGW.
I have listed few of the compilers for M$ windows here :http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html#SECTION00041000000000000000

<noflame> MSVC++ is not a open source compiler. It is not a free compiler. It is a compiler which comes at zero cost. There is no reason that VC++ is more compiler than what gcc is. G++ is the standard compiler for most of the Linux platform. There are far more developers using g++. It is more free than MSVC++ is and every would be. Moreover MSVC++ is not available on any other platform else MS Windows. :( . So keep your "more a compiler than gcc" remark with you when you have not used/ or used g++ even once.
</noflame>

siddhant3s 1,429 Practically a Posting Shark

>thanks brother for your knowledge
Thank him for his experience:)

csurfer commented: Ya his experience !!! Well said !!! +2
siddhant3s 1,429 Practically a Posting Shark

Excuse me but why use regex anyways:

>>> lines=['this ends with;','but this ends with:']
>>> print [ x for x in lines if x.endswith(';')]
['this ends with;']
>>>
siddhant3s 1,429 Practically a Posting Shark

Hint:
ord('\x1a')=26
ord('\x05')=5

ord() is a built-in function which returns the ASCII value of the passed charachter.

Edit: @ vegaseat:

#python 2.5.2
>>> c="%s" % '\x1a'
>>> c
'\x1a'
>>> print c
                            #nothing gets printed
siddhant3s 1,429 Practically a Posting Shark

As AD said, your program contains a lot of magic numbers which is not a good thing to do.
Do not use system("pause") it makes your program consume heavy resources. ( and it makes your program non-portable)

Generally as a rule of thumb: you should always pass the size of an array to the function in which you are passing the array itself as there is no way you can determine the size of the array by just its name (inside a function).

siddhant3s 1,429 Practically a Posting Shark

>While you're at it, could you tell me why line 7 is invalid syntax?
Line 7 would have made sense if you had followed the proper syntax of the code tags:
[code=python] // the code which goes here will have // line numbers at left side

[/code]

Anyways, it turns out that you don't even know the proper syntax of if statement. If was not a bad thing if you were migrating from another language, but the fact is that you are starting programming for the first time.

Anyways, this is the proper syntax:

if <condition> :    #notice the colon
        //do something when
        //the condition is true

>I'd like to destroy whatever the source may be...
I would be glad to help you.

PS: Please follow a definitive tutorial or book to study python. The good part is: that there are enormous resources available for you to learn and most of them are free. You could start learning by the official Python Tutorial or perhaps "How to think Like a Computer Scientist" is also a valuable resource

scru commented: Doesn't the fact that he's starting programming for the first time make him more prone to make mistakes? -1
siddhant3s 1,429 Practically a Posting Shark

While you are searching for the solution, you should know that arrays are evil.
You should be working on STL's std::vector instead of traditional array. The following document can help you migrate : http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html#SECTION00052000000000000000

siddhant3s 1,429 Practically a Posting Shark

@zalezog
The code below line 21 has not been touched by me.

>If max is the number of primes ,you originally want then why are you looping to
>maxprimes
Because the OP had maxprimes as his variable. I changed it to max for simplicity. It was the OP's responsibility to convert each occurrence of maxprime to max.

>shouldn't it be .....
Yes it should, but thats OPs job, why are you getting dirty in a dirty code.

Rest of all your suggestion are for (the benefit of ) OP

siddhant3s 1,429 Practically a Posting Shark

>[wow I am still laughing at my opening statement]
Which statement?

Anyways, it would be very tough to troubleshoot if your code is sacred. Try to produce similar code which causes similar error then post it.

Saying anything without code would be senseless.

siddhant3s 1,429 Practically a Posting Shark

Low-level programming isn't sexy anymore. What you are refereing to is machine language. Every one uses it, in a way that all highlevel instructions are actually processed by CPU as machine instruction.
Machine languages are introduced as just for educational purpose. The famous example is the ``Art of Computer Programming" a legendary book by Donald Knuth. Knuth argues that using machine language/ assembly language keeps you close to the machine and let you know how things are actually carried out when you pass a simple instruction.
But he himself don't use (or tell anyone to use) machine language for productive use. Most beginners assumes that a skilled programmer like Knuth is because he write machine code which he actually does not.
Machine languages are depreciated as per the philosophy `` Don't do what a computer can do for you". Hence don't remember machine code when a computer can translate higher instructions to the lower machine code.
Programming in machine language will make you nothing more than 'less productive'.

siddhant3s 1,429 Practically a Posting Shark

Okay, You know what is function overloading in C++, do you?
Lets say you create a function named int greater(int a, int b) which returns the greater of the two integer of either a and b.
You define it as

int greater(int a, int b)
{ if( a> b) return a;
  return b;
}

Now you feel that you also need a function which can check which of the two floats are greater. So you again write another greater() function, this time for float:

float greater(float a, float b)
{ if( a> b) return a;
  return b;
}

Note that this function is exactly similar to the previous one except that it works on float.
Also note that the compiler will automatically call the appropriate function, no matter if you passed two ints as the parameter or two floats. Compiler knows which one to call.
The story doesn't ends here, now you decide that you should perhaps write a similar function for doubles:

double greater(double a, double b)
{ if( a> b) return a;
  return b;
}

So now, you had to write 3 different functions each time for different data types.
The things get worst when you use custom classes since now, you have to write a function greater for them too.

The solution are templates. In this technique (sorry for using such a term, it is not really a technique) you tell the compiler itself to write functions for …

tux4life commented: Always superb explanations :) +9
siddhant3s 1,429 Practically a Posting Shark

How are you compiling?
I compiled your project and it ran fine:

g++ main.cpp fubar.cpp -o output.exe
siddhant3s 1,429 Practically a Posting Shark

It is really when people say : `` I am using Internet as a book". Internet is no book. Internet can be as closely be thought as network of books. Nothing more.
A book is a book. Don't wander much here and there. Stick to one resource for learning. (though you may search as much as you like for a particular reference)

Another thing is that : When you say ``I have a error", do mention the line number where the compiler complaints.
Anyways, do have a look at :http://www.dreamincode.net/code/snippet528.htm