518 Posted Topics

Member Avatar for catchmrbharath

>If i use long for j instead of int will it work??? Yes Edit: [U]Why?[/U] 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 …

Member Avatar for siddhant3s
0
293
Member Avatar for Sky Diploma

Read [url]http://bytes.com/groups/cpp/62066-c-programmers-how-do-you-use-unnamed-namespaces[/url] and [url]http://www.gamedev.net/community/forums/topic.asp?topic_id=535626[/url] Edit: a more appropriate document [url]http://winterdom.com/dev/cpp/nspaces[/url]

Member Avatar for siddhant3s
0
110
Member Avatar for cwarn23

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. …

Member Avatar for cwarn23
0
379
Member Avatar for saalvi

>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 [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]this[/URL]. If …

Member Avatar for siddhant3s
0
173
Member Avatar for vishalag

>[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.

Member Avatar for vishalag
0
414
Member Avatar for seemant_sun
Re: Help

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

Member Avatar for jephthah
1
116
Member Avatar for Achayan

Hint: ord('\x1a')=26 ord('\x05')=5 ord() is a built-in function which returns the ASCII value of the passed charachter. Edit: @ vegaseat: [code=python] #python 2.5.2 >>> c="%s" % '\x1a' >>> c '\x1a' >>> print c #nothing gets printed [/code]

Member Avatar for vegaseat
0
128
Member Avatar for llemes4011

While you are searching for the solution, you should know that [URL="http://www.parashift.com/c++-faq-lite/containers.html#faq-34.1"]arrays are evil[/URL]. You should be working on STL's std::vector instead of traditional array. The following document can help you migrate : [url]http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html#SECTION00052000000000000000[/url]

Member Avatar for Narue
0
101
Member Avatar for pupspark

>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: [noparse][code=python] // the code which goes here will have // line numbers at left side [/code][/noparse] Anyways, it turns …

Member Avatar for siddhant3s
0
206
Member Avatar for asifjavaid

@Tux4life Your beautiful post has nothing to do with OP's problem. The construct use for allocating space using malloc is absolutely valid in C. The only problem is on line: void* ptr = buf_ptr[20]; as Beair.GQ said, you are assigning a void to void*. The type of buf_ptr[i] is not …

Member Avatar for asifjavaid
0
2K
Member Avatar for athlon32

How are you compiling? I compiled your project and it ran fine: [code] g++ main.cpp fubar.cpp -o output.exe [/code]

Member Avatar for athlon32
0
113
Member Avatar for Vermillion

Okay, You know what is function overloading in C++, do you? Lets say you create a function named [U][I]int greater(int a, int b)[/I][/U] which returns the greater of the two integer of either [I]a[/I] and [I]b[/I]. You define it as [code=cpp] int greater(int a, int b) { if( a> b) …

Member Avatar for ShawnCplus
0
117
Member Avatar for Vermillion

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" …

Member Avatar for Vermillion
0
298
Member Avatar for Agni

Depending on your platform, you can time your application for a given set of data. Or you can use a [URL="http://en.wikipedia.org/wiki/Performance_analysis"]profiler[/URL] . But whatever you do, please don't optimize your code without analyzing its performance. Optimize only and only when you really need it.

Member Avatar for tux4life
0
458
Member Avatar for sravan953

>I know it has to be a loop, but which function? Why are you so sure? [code=python] >>> s="asdf<script" >>> print s[:s.find('<')] asdf >>> [/code]

Member Avatar for siddhant3s
0
106
Member Avatar for stark025

Works for me: g++ on Linux [code=cpp]#include<iostream> #include<string> static const char * sql_backslash_to_underscore(const char * key) { if (!key) { //ERROR0("got NULL key"); return NULL; } std::string rep = key; std::replace(rep.begin(), rep.end(), '\', '_'); return rep.c_str(); } int main() { std::cout<<sql_backslash_to_underscore("acct\\username"); }[/code] [code] siddhant3s@Xion:~$ g++ tester.cpp -o tester siddhant3s@Xion:~$ ./tester …

Member Avatar for Ancient Dragon
0
194
Member Avatar for KuriYokan

Your problem, what I am perceiving is, that you want to have an interface for your class which can return the c-string for [I]name[/I] but don't let user change it. Returning a pointer is not a good idea overall. Change your signature of the get function as: [code=cpp] void getName(char* …

Member Avatar for Sky Diploma
0
156
Member Avatar for revenge2

OMG, the OP is answering his own question..... oh wait..... So you are twins !! That took me a while after noticing that you both share the same avatar. > as you know for an array > &array[0] = array, > so we just pass in the name of the …

Member Avatar for csurfer
0
109
Member Avatar for themaster

>I dont know which one to download from where and how to use it. So, [URL="http://www.all-acronyms.com/STFW"]STFW.[/URL]. Salem has already told you twice to use curses( or ncurses or pdcurses) but look at you.... you are not even bothered.

Member Avatar for Ancient Dragon
0
293
Member Avatar for animefun2

>I'd suggest a final step of randomly shuffling the values. That can complicate things. I would suggest OP that: after assigning values 0 to 9 to all those 20 location, choose a location randomly and assign value zero to it.

Member Avatar for seemant_sun
0
196
Member Avatar for atman

>static arrays are ............ You meant to say "fixed-length" arrays, right? OP>in here i cant set the array size from function receiving argument? and why? Because, array size should be a compile time constant, that is: the array size should be known at the compile time. You are already been …

Member Avatar for siddhant3s
0
123
Member Avatar for vivek3227

>Can ne1 tell me how 2 write a c++ program to find out the determinant of a (mxn ) >matrix Determinants are only defined for square matrix. A far as writing of the program is concerned: [U]"NO ONE IS GOING TO WRITE IT AND DELIVER IT TO YOU"[/U] The [U]ONE[/U] …

Member Avatar for siddhant3s
0
124
Member Avatar for john_beginner

I won't have to. When you create an object of class C, both get_a, get_b will be available for calling. If however, both function was named get(), then it would cause ambiguity. [code]class A { protected: int no; public: void get(void) { cout<<"Class"; } }; class B { protected: int …

Member Avatar for indianapple89
0
109
Member Avatar for timb89

Recursive functions is almost never a good idea if you are aiming for speed. Recursive functions however, are easier to conceptualize than iterative functions. They goes with philosophy ``Developers time is far more important than machine time." However, on languages such as C, C++ recursive functions are not 'so bad' …

Member Avatar for Stinomus
0
1K
Member Avatar for dingletoo

Use urllib to fetch the ftp directory: [code=python] >>> a=urlopen('ftp://ftp.cs.stanford.edu/pub/cweb/') >>> a=a.read() >>> print a drwxr-xr-x 3 ftp users 4096 Oct 24 2006 . drwxr-xr-x 49 sybase sybase 4096 Dec 11 2008 .. -rw-r--r-- 1 ftp users 4962 Dec 29 2003 Makefile -rw-r--r-- 1 ftp users 4950 Feb 14 2002 …

Member Avatar for siddhant3s
0
65
Member Avatar for Kob0724

Just add [icode]typname[/icode] before [icode]RangeToValidatorMap::const_iterator it;[/icode] to make it [icode]typename RangeToValidatorMap::const_iterator it;[/icode] Now try to find out using web, why this fixed the problem. Get back here if you don't find anything.

Member Avatar for siddhant3s
0
174
Member Avatar for gretty

Your not catching the value return by the function. [code=cplusplus]#include <iostream> using namespace std; enum months {jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}; months nextMonth(months& currentMonth); int main() { months a = nov; a=nextMonth(a); cout << a << endl; return 0; } months …

Member Avatar for yun
0
173
Member Avatar for dumrat

>Can anyone tell me the answer? Or if it can not be done? ArkM has beautifully answered your question. Open your mind to see this. I would again like to point out ArkM's last point: If you are a C++ programmer, you should know that Macros are evil. Look at …

Member Avatar for ArkM
0
129
Member Avatar for yazooney

Each program on specific operating system is alloted its own memory space which is usually parted into 3 components: stack, heap and data. When you say that you know the value at location 0x245CEA20, You may be mistaken!! Suppose I have a variable named [I]a[/I] in a program A which …

Member Avatar for yazooney
0
3K
Member Avatar for timb89

If it bothers you, try to be expressive while writing your code: Use iterators. learn the reverse iterators at [url]http://www.cplusplus.com/reference/string/string/rbegin/[/url] After you read the example there, study the following code: [code=cplusplus]bool isrev(string s1,string s2) { string::reverse_iterator rit; string::iterator it; if(s1.size()!=s2.size()) return false; for ( rit=s1.rbegin(),it=s2.begin(); rit < s1.rend()&&it<s2.end(); rit++,it++ ) …

Member Avatar for ArkM
0
108
Member Avatar for gnobber

Ok, What you want is a bit informal explanation. Think of stream as a virtual device (presumably a printer). You are give functions to read/write to that device. You actually don't differentiate if that device is actually your monitor, your printer, the hard disk, or the RAM. What you know …

Member Avatar for sai sushma
0
154
Member Avatar for zoro007

>Sometimes the simplest solution is the best one. Sometimes simplest solution is not the portable one. Your solution lean on grep to be available. [code=python]f=open('file.txt'); lines=f.readlines(); for l in lines: # remove .lstrip() from the following next line, if you don't want to be strict. # Any whitespace wont stripped …

Member Avatar for siddhant3s
0
126
Member Avatar for deostroll

>How do we output value in register AX? How can you be so sure that your computer has a register? C++, or any compiler doesn't know about registers. C++ also runs on those computer which doesn't have registers. So, don't go at much lower level with a language as C++.

Member Avatar for ArkM
0
107
Member Avatar for Aseem_Pandey
Member Avatar for siddhant3s
0
269
Member Avatar for ithelp

[QUOTE=PcPro12]mine is probably the space bar, since I always use it to press space......[/QUOTE] Yeah, but we use space bar key to press delete. Me a Emacs user: What can you expect. The left control key. There is nothing written on it. Space has gotten much older but there was …

Member Avatar for vegaseat
0
164
Member Avatar for shinkelwars

>As C++ developer - stop finding ready-made code or solution otherwise you will >mess up your work. "Good programmers know what to write. Great ones know what to rewrite (and reuse)." He is not looking for "homework helps". He is trying to exercise what is one of the well known …

Member Avatar for Ancient Dragon
0
149
Member Avatar for KuriYokan

The whole concept of Template is to exploit the fact that interface of the data-type passed is same. Consider std:;sort() it takes the vector of any container which have overloaded > operator. That is, template are used to perform type-unspecific operations. If you are needing a way to check if …

Member Avatar for KuriYokan
0
139
Member Avatar for max.yevs

Use simple boolean statements. Here is my python interaction: [code=python] >>> a = [1,2,3,4,5,6,7,8,9,10,10,10] >>> b = list(input ("Enter numbers: ")) Enter numbers: [3,4,10] >>> a= [x for x in a if x not in b] >>> a [1, 2, 5, 6, 7, 8, 9] >>> [/code]

Member Avatar for shadwickman
0
174
Member Avatar for zoro007

Try not to confuse people. Those who knows python does not necessarily know bash. The same way you know bash but do not know python. BTW, here is your code: [code=python] s="dani_web_needs_better_OP" print s.split("_")[1] [/code] One more advice, try to read a book. These things are covered in the introductory …

Member Avatar for zoro007
0
110
Member Avatar for Pavan_

[U]About negative subscript in arrays and array notations[/U] Consider the following code: [code=c]#include<stdio.h> int main() { int ia[]={0,1,2,3,4,5,6,7};/*a normal array*/ int* ip=&ia[4];/*a pointer pointing to 5th element*/ /*WRONG: will print garbage. Unpredictable value*/ printf("%i \n",ia[-3]); /*OK. Prints 1*/ printf("%i \n",ip[-3]); return 0; }[/code] The Line 11 will be interpreted as …

Member Avatar for ArkM
0
148
Member Avatar for kasumi01

Look at lines dvd movie; movie(lista); in int main() What do you want [U]movie[/U] to be: a function or a [I]dvd[/I] structure?. Use a different name for the object or a different name for the function. Note that it is alright to declare a dvd called movie in main(). But …

Member Avatar for kasumi01
1
227
Member Avatar for Mudi

>the main prob is i m a beignner and i have to submit my assignment soon Your only problem is that you have NOT read a book. Go and get one and read it. You have not impressed us a bit so that we should help you. also read [URL="http://www.catb.org/~esr/faqs/smart-questions.html"]How …

Member Avatar for siddhant3s
0
117
Member Avatar for mimio134
Member Avatar for gretty

>>But I dont know the correct way to do it? What you are doing is ``just" acceptable. It is no where near to what one would called a good code. I suggest you to use the infamous Unix philosophy KISS( Keep it Simple and Stupid). Although I am not a …

Member Avatar for siddhant3s
0
265
Member Avatar for catchmrbharath

Simple, Use file I./O. Or you can also use the input redirection operator '<' while calling the program from the command prompt [icode]$ myprogram.exe < input_data.txt[/icode]

Member Avatar for s_sridhar
0
152
Member Avatar for catchmrbharath

>I can't understand why your brutal force algorithm is so expensive It will certainly not be. But he may be getting 100 of Input tests at once. So it may exceed the time limit ( which is about 2-3 seconds ).

Member Avatar for ArkM
0
138
Member Avatar for san gabriel

To tux:[url]http://www.cplusplus.com/reference/iostream/istream/getline/[/url] "Characters are extracted until either (n - 1) characters have been extracted or the delimiting character is found (which is delim if this parameter is specified, or '\n' otherwise). The extraction also stops if the end of file is reached in the input sequence or if an error …

Member Avatar for mirfan00
0
446
Member Avatar for swisschris104

Now thats what I call a script kiddie. >I Can Program basic Online Codez :CSS and HTML. You do not program in HTML. HTML is not a programming language. It is a markup language. Consider yourself quite lucky. Because hackers don't usualy repsonz 2 sm1 who cnnt wrte pr0per1y. Plz …

Member Avatar for Narue
0
134
Member Avatar for hiscasio

Oh man! Did anyone told you that you should have been using the post tags: [noparse] [code=cplusplus] //paste the code here [/code] [/noparse] Anyways, your code is awful. I am sure you would be programming in a Old-style compiler (perhaps TC++ ). Read this:[url]http://cppdb.blogspot.com/2008/10/why-you-shouldnt-use-you-use-old-c.html[/url] You have not coded the main() …

Member Avatar for hawash
0
148
Member Avatar for catchmrbharath

The first optimization advice is "[URL="http://c2.com/cgi/wiki?PrematureOptimization"]Don't optimize anything[/URL]". Second advice: Stick to one language C or C++. You are using lot of scanfs and printfs. It goes without say that post your code it code tags: [noparse] [code=cpp] //your code [/code] [/noparse]

Member Avatar for Sky Diploma
0
145

The End.