825 Posted Topics

Member Avatar for user543820

Why convert to binary tree? Is it even possible to convert from NxM grid to binary tree and keep the semantics of your 'grid'?

Member Avatar for L7Sqr
0
124
Member Avatar for james6754

C++ does not prevent you from accessing outside the bounds of an array. If you want exceptions on bounds checks look into standard containers that provide this type of thing. Here is an example using [icode]std::vector.at()[/icode][code]#include <vector> int main () { std::vector< int > v(10); for (int i = 0; …

Member Avatar for jbennet
0
116
Member Avatar for msrikanth

[EDIT] Sorry, forgot this was not the C forum. See below if you'd also like the C implementation. Bash script for lines and columns:[code]#!/bin/bash echo "cols: `tput cols`" echo "lines: `tput lines`"[/code] [/EDIT] The following will print out the number of rows/columns but I'm not sure of how to get …

Member Avatar for msrikanth
0
2K
Member Avatar for nakresimin

If you want to empty the tables of a database you are going to, at some point, use the facilities provided by the database designers to do so. This may be a command line script to drop tables or a program that uses the database API to do it programatically. …

Member Avatar for JeoSaurus
0
85
Member Avatar for RobotFX

[code]$ pushd /Stallone/photos $ mv * ../ $ popd $ pushd /Aguilera/photos $ mv * ../ $ popd[/code] Of course, this moves [i]everything[/i] in the photos directory up one level - including other directories. You could limit that with globbing. For instance [icode]mv *.png ../[/icode] would only move files ending …

Member Avatar for RobotFX
0
113
Member Avatar for Labdabeta

It'd be helpful, as a start, if you gave an idea of what was going wrong. There is a lot of code there and even more context in your head that we are not privy to.

Member Avatar for Labdabeta
0
351
Member Avatar for sfurlow72

The first example associates the const-ness with the value returned from the call. In the second example you are specifying that the call can not modify the object being invoked.

Member Avatar for L7Sqr
0
181
Member Avatar for triumphost

[icode]delete p;[/icode] [i][b]invokes[/b][/i] the destructor for pointers. Putting a call to [icode]delete[/icode] in a destructor is only applicable if there is memory maintained within the object itself.

Member Avatar for triumphost
0
762
Member Avatar for kuramahiei

When reading character-by-character you have to be aware of the newline in the buffer. Consider the following:[code]#include <iostream> int main () { char c = 0; while (std::cin.get(c)) { if (c == '\n') std::cout << "<NEWLINE>" << std::endl; else std::cout << c << std::endl; } return 0; }[/code] and the …

Member Avatar for kuramahiei
0
172
Member Avatar for triumphost

[quote]Examples of copyright infringement may include borrowing significant portions of another's work in the creation of a new work...[/quote] From [url=http://www.lib.uconn.edu/copyright/plagiarismVsCopyright.html]here[/url]. I am certainly not a laywer. For a definitive answer you need to read the GPL license and probably contact a legal authority.

Member Avatar for mike_2000_17
0
103
Member Avatar for utkarshsahu

[b]WaltP[/b] is suggesting that you mention errors but do not provide them. This requires us to now copy, paste and compile your code - likely on a different platform and with a different compiler than your own. If you copied the errors you were getting it would be helpful. Also, …

Member Avatar for utkarshsahu
0
184
Member Avatar for sridhar.selva

Yes, you can. You can not have conflicting values, however. For instance, the following will not work:[code]enum enum1 { FOO , BAR } e1; enum enum2 { BAR, BAZ } e2;[/code] due to the redefinition of the enum tag [icode]BAR[/icode]

Member Avatar for sridhar.selva
0
166
Member Avatar for sudhanshu12788

Using [icode]sed[/icode] you can look for spaces and tabs [icode][ \t][/icode] (extended regular expressions will allow modifiers to that). Then you can replace with a comma. The general format of the sed search/pattern/replace is: [icode]s/PATTERN/REPLACEMENT/g[/icode] I added the [icode]g[/icode] on the end as it is a modifier to include all …

Member Avatar for deepkw
0
212
Member Avatar for Emfemmi

You could specialize for the same type. Something similar to :[code]template< class T1, class T2 > class Different { public: Different(const std::pair< T1, T2 >& somePair) { l2r.insert(somePair); r2l.insert(std::make_pair(somePair.second, somePair.first)); } virtual T1 find(const T2& key) { return r2l[key]; } virtual T2 find(const T1& key) { return l2r[key]; } private: …

Member Avatar for L7Sqr
0
207
Member Avatar for buckeyemike

The following line looks problematic:[code]fileVector entry(string firstname,string lastname,string idnumber,string class1, string class2,string class3,string hours,string classification,string degreetype, string thesis );[/code] Your compiler should have complained about that in that you are not allowed to have types next to the arguments in a constructor or function call. You error is probably related …

Member Avatar for darthstewie
0
3K
Member Avatar for Labdabeta

For an introduction, look at [url=http://en.wikipedia.org/wiki/Huffman_coding]Huffman Encoding[/url]. There is certainly [i]much[/i] more than just that - but it should give you a start to get an understanding.

Member Avatar for Labdabeta
0
250
Member Avatar for Zssffssz

Is there any reason you cant use a [url=http://msdn.microsoft.com/en-us/library/windows/desktop/ms682022(v=vs.85).aspx]programmatic[/url] approach. Or, at the minimum just output a large amount of blank lines?

Member Avatar for Zssffssz
0
127
Member Avatar for tom12

I'd suggest you move to C++ containers ([icode]std::string, std::remove_copy_if[/icode]) to make your life easier but that is another issue. The easiest way to remove elements from an array is to create a new array of exactly the same size as the original. Loop over each value in the original array …

Member Avatar for Ancient Dragon
0
105
Member Avatar for python_adz

Show us what code you [i]did[/i] use and perhaps we can help you understand why it did not work.

Member Avatar for L7Sqr
0
107
Member Avatar for woodson2

Well, the effect is due to how your are writing ([icode]>>[/icode]) to the file not necessarily due to the HERE document. I can think of a couple of solutions that may work depending on your setup. If you have a set front matter and tail matter you can place them …

Member Avatar for L7Sqr
0
102
Member Avatar for _Nestor

Containers are permitted as template arguments. Consider:[code]template < typename T, class E > bool contains (const T& haystack, const E& needle) { typename T::const_iterator F = haystack.begin(), L = haystack.end(); for (; F != L; ++F) if (*F == needle) return true; return false; }[/code] You can use that like:[code] …

Member Avatar for _Nestor
0
258
Member Avatar for triumphost

What would be the point of overloading two operators at the same time? Suppose you did what you were suggesting in your post - you would get functionality similar to [icode]data[x] = y[/icode]. What happens if you want to read that variable now? There is no support for just [icode]data[x][/icode] …

Member Avatar for Banfa
0
261
Member Avatar for Vladnaka

There are libraries that try to provide this behavior across multiple platforms. [url=http://pdcurses.sourceforge.net/]PDcurses[/url] is one example.

Member Avatar for jaskij
0
253
Member Avatar for triumphost

I don't have the context of your previous conversation, but why would something like a vector not work for you?[code] M& Insert(std::vector< MyTypes >& args) { for (int I = 0; I < args.size(); ++I) P.push_back(Args[I]); return *this; }[/code]

Member Avatar for triumphost
0
213
Member Avatar for Suzie999

It depends on who you want to manage the memory. If you have an agreement with the caller that the returned pointer is now 'owned' in the calling context then return dynamic memory as suggested by [b]gerard4143[/b]. This requires that the contract be upheld or a memory leak will occur. …

Member Avatar for Suzie999
0
129
Member Avatar for alaa sam

Supposing you have sudo abilities, just open the terminal you are most used to and enter [icode]sudo bash[/icode]. Root shell session. Feel free to substitute [icode]bash[/icode] with your favorite shell, of course.

Member Avatar for alaa sam
0
408
Member Avatar for Aamit

You can not return a string. You must return a numeric value. So changing [icode]"$fileName__0"[/icode] to something like [icode]0[/icode] would work.

Member Avatar for thekashyap
0
852
Member Avatar for LRNPHP
Member Avatar for LRNPHP
0
124
Member Avatar for sridhar.selva

You will have to check the value of [icode]errno[/icode] to find the exact problem. From the man pages of [icode]write[/icode]:[code]ERRORS EBADF fd is not a valid file descriptor or is not open for writing. EINVAL fd is attached to an object which is unsuitable for writing. EFAULT buf is outside …

Member Avatar for sridhar.selva
0
416
Member Avatar for Labdabeta

Are you sure your implementation of [icode]new[/icode] doesn't already provide virtual memory backed by disk space? Have you run into the issue of [icode]new[/icode] returning NULL (as opposed to throwing [icode]bad_alloc[/icode])?

Member Avatar for Labdabeta
0
173
Member Avatar for koricha

It removes html/xml style tags from the input file. [code] s/ # Search for ... < # Something that begins with '<' [^>] # and continue while there isn't a '>' * # for zero-or more characters > # Ending with a '>' character // # replace previous match with …

Member Avatar for koricha
0
176
Member Avatar for subith86

How, with the first method, would you expect to support something like [icode]a = b = c;[/icode]?

Member Avatar for subith86
0
135
Member Avatar for MrAppleseed

The way [b]Banfa[/b] suggests is a common way to do this. Macros are another way you will see. Something like[code]#define MAKE_COMMON_FOO(f,fun) struct foo f; \ f.func = fun[/code] Which would be used like[code]MAKE_COMMON_FOO(bar,func); bar.func(4);[/code] The advantage of the macro is that as the struct evolves the changes to the code …

Member Avatar for L7Sqr
0
112
Member Avatar for MrEARTHSHAcKER

Your examples are mixing character variables with integer variables and looping over different ranges. I'm not sure why you expect common behavior if you do not provide common code...

Member Avatar for MrEARTHSHAcKER
0
176
Member Avatar for ChevyScience

Probably because you are giving input [icode]1 4[/icode] instead of [icode]1 3[/icode].

Member Avatar for ravenous
0
171
Member Avatar for Esmerelda

Neither case will work for me. The tags for case statements must be constants, they can not be the result of a function call. It might be the case that, on your platform, the [icode]isdigit[/icode] is evaluated at pre-processor time to be 1 allowing for you to compile. Can you …

Member Avatar for WaltP
0
127
Member Avatar for emmasmart

A good programmer is a problem solver first. If you can not solve problems programming chops are a moot point. Also, this is the C forum, your topic (and question) are off-topic for this area. Consider, instead, the [url=http://www.daniweb.com/community-center/3]Community Center[/url].

Member Avatar for Moschops
0
114
Member Avatar for capton

Superscripts and subscripts are an artifact of a rendering process; they are not native to the C++ language.

Member Avatar for DeanMSands3
0
415
Member Avatar for prasenjit_das

You must be careful with what you are asking. A pointer to a [icode]std::string[/icode], a pointer to a character array and a [icode]std::string[/icode] are all distinct and the process by which you concatenate will be different for each. What types are you dealing with?

Member Avatar for L7Sqr
0
163
Member Avatar for jmichae3

You may look at how other cross-platform software does this. Consider boost - which is fairly compatible on multiple platforms. In boost you will find a [icode]select_platform_config.hpp[/icode] which has code similar to[code]#if defined(linux) || defined(__linux) || defined(__linux__) // linux: # define BOOST_PLATFORM_CONFIG "boost/config/platform/linux.hpp" #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) // …

Member Avatar for L7Sqr
0
115
Member Avatar for muthu1802

You want to connect as a new user or you want to connect as the same user with different credentials?

Member Avatar for muthu1802
0
198
Member Avatar for newbie1234

You want a [i]function generator[/i] or a function that will generate a 128bit random [i]number[/i]? You may be out of luck for a function generator. As for the random number, [url=http://stackoverflow.com/a/1546037/128138]this[/url] has a lot of relevant information.

Member Avatar for newbie1234
0
1K
Member Avatar for Gaiety

The [icode]test: extra argument `how'[/icode] should tip you off that it's not your program running. Try renaming your program to something like [icode]foo[/icode] and try again. Your shell already has a binary named [icode]test[/icode] that will be used by default. By not providing an explicit path, you have invoked the …

Member Avatar for Gaiety
0
167
Member Avatar for phorce

You create enough room for a single int with [icode]int * data2 = new int();[/icode] You are accessing that memory as if it were an array. You probably mean [icode]int * data2 = new int[MAX_SIZE];[/icode] where [icode]MAX_SIZE[/icode] is the size of the array you want to support. Either that, or …

Member Avatar for phorce
0
122
Member Avatar for raul8

When I run your example I get [code]/user/test /user/test/program[/code]I fail to see how that differs from what you want.

Member Avatar for Fest3er
0
133
Member Avatar for MasterHacker110

There isn't any reason to delete the two you are not using. They aren't hurting anything. If you only want a single installation on your machine then you need to re-install the OS and force it to remove existing partitions and use the entire disk.

Member Avatar for dolphinalex
0
204
Member Avatar for tahsin.rahit

[icode]graph *g;[/icode] creates a pointer (to memory) but you fail to provide any memory to point to. You can do one of three things: [LIST] [*] Create an object instead of a pointer ([icode]graph g;[/icode]) [*] Create an object and assign the pointer to that objects address ([icode]graph g, *gp …

Member Avatar for mike_2000_17
0
252
Member Avatar for Labdabeta

Consider why you must convert to C. I cont see many reasons where C would be necessary over C++.

Member Avatar for Ancient Dragon
0
179
Member Avatar for Labdabeta

If you quote that then you should have no problem. For instance:[code]#define BLOCK(msg) blockHandler(msg) void blockHandler(const std::string& blk) { std::stringstream ss(blk); std::string s; while (ss >> s) std::cout << "Token: " << s << std::endl; } int main () { BLOCK("This is a quoted block in the program"); return 0; …

Member Avatar for Labdabeta
0
295
Member Avatar for niyasc

They are bash variables. Look for 'special parameters' [url=http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html]here[/url].

Member Avatar for adrianfrederic
0
89

The End.