I have a simple question about unicode and utf8. How does a utf8 encoding know what its uppercase encoding is? I understand how utf8 encoding carries its unicode value embedded in itself but I fail to see how it maps a utf8 encoding to an uppercase unicode value. What is the mechanism which maps utf8 encodings to uppercase encodings or the other features available in the unicode universe?

Member Avatar
Member Avatar
+0 forum 3

I'm curious as to where a member would post a question on ML(Ocaml) type language?

Member Avatar
Member Avatar
+0 forum 3

Does anyone know how to do this? I attached a program that collects all the command line arguments into a map container noting how many times each command line argument occurs. Now I want to sort this map of information by loading a vector with iterators that point to each map element and sort the iterators. I'm just wondering, what is the best way to do this. My method works but I'm wondering is it the proper way to do it?. #include <iostream> #include <string> #include <vector> #include <map> #include <iterator> #include <algorithm> struct mys { unsigned long a; }; …

Member Avatar
Member Avatar
+0 forum 3

I have a question about istream iterators and reading the input to the EOL. How do you do it? I tried the following but had to revert to a hack to get it to work. My first attempt reads from the istream but a word at a time. first.cpp #include <iostream> #include <string> #include <vector> #include <iterator> int main(int argc, char** argv) { std::vector<std::string> the_words; std::istream_iterator<std::string> in(std::cin); std::istream_iterator<std::string> CIN_EOF; while ( in != CIN_EOF ) { the_words.push_back(*in); ++in; } std::vector<std::string>::const_iterator begin = the_words.begin(); std::vector<std::string>::const_iterator end = the_words.end(); std::vector<std::string>::size_type count = 0; while ( begin != end ) { std::cout << …

Member Avatar
Member Avatar
+0 forum 1

Please delete this...I'm new to the new Daniweb format.

Member Avatar
+0 forum 0

Is it possible to pass a map container to the copy algorithm and display it to the std::cout? If so how? What I tried below doesn't work but it looks like it should. Any comments or pointers will be appreciated. [code] #include <iostream> #include <string> #include <map> #include <algorithm> #include <iterator> std::ostream& operator<<(std::ostream & out, const std::pair<std::string, unsigned long> & p) { return out << p.first << " " << p.second; } int main(int argc, char**argv) { std::map<std::string, unsigned long> the_words; for (int i = 1; i < argc; ++i) ++the_words[argv[i]]; std::map<std::string, unsigned long>::const_iterator begin = the_words.begin(); std::cout << *begin …

Member Avatar
Member Avatar
+0 forum 17

I'm really new to C# so this may seem like a novice question..How does C# accomplished passing a reference to a object reference? I'm really trying to understand the underlying mechanisms and how it applies to the attached code with the comments - //what happens here? Do we pass a ref->ref->ref....or is this accomplished via reference counting. [code] using System; class my_int{ int itsx; int itsy; public my_int(int x, int y){ itsx = x; itsy = y; } public void display_it(){ Console.WriteLine("x->{0}, y->{1}", itsx, itsy); } } namespace testit { class MainClass{ static void myfunc(ref my_int m, int x){ if …

Member Avatar
Member Avatar
+0 forum 4

Hi, I have an odd problem...well an annoying problem. My internal hard drive is read only which is O.K. unless you need to write to it or say boot it. So what happened? I really don't know, I sent my computer to get some maintenance done on it because it won't boot, won't power up, it won't even go so far as post any POST errors. It was dead...Wait a minute, I think the power supply fan worked anyways the Acer maintenance people said I had a bad RAM module and they replaced it and said the computer is now …

Member Avatar
Member Avatar
+0 forum 3

How do you initialize a dynamic structure that has a const data member? I can provide an ugly hack but I'm at a loss as how to do it correctly. Actually, can you do this in a platform independent way? [code] #include <stdio.h> #include <stdlib.h> struct mys { const int value; }; int main(int argc, char**argv) { struct mys *sptr = (struct mys*)malloc(sizeof(struct mys)); *(int*)sptr = 1234; fprintf(stdout, "ans->%d\n", sptr->value); /*sptr->value = 67;*/ return 0; }[/code]

Member Avatar
Member Avatar
+0 forum 10

Hi, I'm looking for a good book on Qt 4 programming, I checked both chapters and amazon but couldn't locate a Qt book with favorable reviews and was wondering if the daniweb members knew of a good text...Thanks in advance. Gerard4143

Member Avatar
Member Avatar
+0 forum 2

I'm wondering what is the proper way to point at an overloaded function. Is it correct to cast the function to the proper type? [code] #include <iostream> int double_it(int x) { return x * 2; } int double_it(int x, int y) { return (x + y) * 2; } int main(int argc, char**argv) { void *myfunc = (void*)(int(*)(int))double_it; return 0; } [/code]

Member Avatar
Member Avatar
+2 forum 3

Have you read this? [url]http://arstechnica.com/open-source/news/2010/10/shuttleworth-unity-shell-will-be-default-desktop-in-ubuntu-1104.ars?utm_source=rss&utm_medium=rss&utm_campaign=rss[/url]

Member Avatar
Member Avatar
+0 forum 6

I have a question about function precedence. How does the compiler decide which function to call in quasi ambiguous situations? Is it laid out in the standard or is it implementation dependent? If you look at the attached code you'll see I'm outputting the value contained by the myint object. Now I can remove the overloaded output operator and the program will appear the run exactly the same because it will use the conversion operator 'operator int()'. So how does the compiler choose? Is it vendor specific or is it decided by the standard? I tried googling but I keep …

Member Avatar
Member Avatar
+0 forum 2

Am I correct assuming that a reference to an object will not call the object's destructor when the reference goes out of scope? The code I attached supports my assumption but I'm not certain if its correct...Any comments? [code] #include <iostream> class myint { public: myint():itsvalue(0) {} myint(unsigned long val):itsvalue(val) { std::cout << "constructing->" << itsvalue << std::endl; } ~myint() { std::cout << "destroying->" << itsvalue << std::endl; } std::ostream& print(std::ostream & out) const { return out << itsvalue; } private: unsigned long itsvalue; }; std::ostream& operator <<(std::ostream & out, const myint & m) { return m.print(out); } myint& myfunc(void) …

Member Avatar
Member Avatar
+0 forum 3

I have a simple question about objects and exception handling. What happens to an object after its thrown? Does the implementation take of cleaning up that object or should I be aware of any situations that may require extra care...I've read this from - Inside The C++ Object Model by Stanley B. Lippman pg 261 "When an exception is thrown, the exception object is created and placed generally on some form of exception data stack" This is great to know but I can't find any mention of what happens to that object after the exception is finished...Could someone please enlighten …

Member Avatar
Member Avatar
+0 forum 2

Hi, Is there ever a situation where the programmer needs to be concerned about the copying of a vtable pointer or can I happily assume that the C++ language will handle that detail correctly without my intervention?

Member Avatar
Member Avatar
+0 forum 3

Hi, I have a question about constructors and the difference between passing by value and by reference. If you look at the two examples I attached. Example one has a constructor that passes by value and example two pass by reference. Now I want to know why example one will use the constructor: myc():itsvalue(0) {} to convert this line myc m(123, 456); and work but example two will fail to compile saying no valid constructor found..Why does this happen? Example-One [code] #include <iostream> class myc { public: typedef unsigned long size_type; myc():itsvalue(0) {} myc(size_type val):itsvalue(val) {} myc(myc a, myc b):itsvalue(a.itsvalue …

Member Avatar
Member Avatar
+0 forum 2

Here's the newest 64 bit Flash Player from Adobe Labs....Way to go Adobe... [url]http://labs.adobe.com/downloads/flashplayer10.html[/url]

Member Avatar
+0 forum 0

Could someone please verify. Is it proper to have pointers to containers(vectors in this example) where you allocate memory for them and then free them. I googled and found a posting that stated its considered poor coding style to do this...I doesn't seem like it should be poor programming style to me. struct student contains the pointer std::vector<double> *assignments; Which I allocate in the program and then free towards the end with.. for (i = 0; i < the_students_size; ++i) { the_students[i].assignments->clear(); delete the_students[i].assignments; } [code] #include <iostream> #include <string> #include <vector> #include <algorithm> //struct with pointer to vector.... struct …

Member Avatar
Member Avatar
+0 forum 4

Hi, I'm looking for a book on C++...now before you flame me I did read the sticky "Read Me:C++ Books" and found the list interesting but for me uninformative...Why? I'm not really sure what C++ level I'm at currently. Let me elaborate...Here's my experience with the C family of languages.. I've been programming daily in the C language for about two years now, so I'm comfortable with the language but C++?? Well I did read/work through Sams 'Teach Yourself C++ in 21 Days' and have been picking at the language(C++) on again and off again for some time now but …

Member Avatar
Member Avatar
+0 forum 14

Please check the line(s) of code after the comments '//this is the line of code in question... '. I want to know if this is the proper way to use the std::ostream operator<< in multi-inheritance? Basically I want the derived object(dog) to call the base object's std::ostream operators without hard-coding it....Please note the program works, I'm just looking for a verification. Is this the proper way to use the std::ostream operator in this program? [code] #include <iostream> class animal { public: animal(const char *name):itsname(name) {} virtual ~animal() {} friend std::ostream& operator<<(std::ostream & out, const animal & rhs); protected: const char …

Member Avatar
Member Avatar
+0 forum 6

I have a question about functions and pointers to functions.... Why does a C program treat a function call to a function and a function call to a function pointer the same? [CODE] #include <stdio.h> #include <stdlib.h> typedef void (*funcptr)(void); void myfunc(void) { fputs("Hello, World!\n", stdout); } int main(int argc, char**argv) { funcptr MyFunc = &myfunc; myfunc(); MyFunc(); exit(EXIT_SUCCESS); } [/CODE] Program output: [code] Hello, World! Hello, World! [/code] When I compile the above program both the call to myfunc() and MyFunc() will produced the same result..."Hello, World" will be displayed. Now when I examine the asm instructions for this …

Member Avatar
Member Avatar
+0 forum 12

I have a question, well more of a verification. In the program below, I'm packing a character array with some values. The first two are unsigned integers the next is a function pointer and the final is a string of characters...Now my question, is the casting correct for the function pointer? Just check the sections marked off with /*this section*/. [CODE] #include <stdio.h> #include <string.h> #define MAXLINE 4096 char *ca = "this is the string to pass"; void myhello(void) { fputs("Hello, World!\n", stdout); } int main(int argc, char**argv) { unsigned int i = 0; char recvline[MAXLINE]; *(unsigned int*)&recvline[0] = 11111; …

Member Avatar
Member Avatar
+1 forum 7

Hi, I have a simple question about the Linux Shebang '#!'. Well more of a clarification of how Linux handles #!. My understanding.... When the operating system 'Linux' encounters an executable file with the first characters #! it will extract the absolute path for the executable from this line..i.e. #! /home/gerard/share/test/gg Linux will extract the path '/home/gerard/share/test/' and executable 'gg'. Linux will then replace the potential process with this image and pass as command line arguments - the name of the file that called it and possible addition arguments.. Now the interrupter(mine is gg) will execute, reading the command line …

Member Avatar
Member Avatar
+0 forum 2

Hi, I wrote this simple bash script(yeah simple now that its done) and it uses bc - 'The arbitrary precision calculator language' and tr - 'translate or delete characters'. Now the script works, it will take input values and convert them to the proper output values. Now my question is..is this the proper way to do it? I'm not very experienced with shell scripting...well anything complicated. script usage: cnvt value inbase outbase example: cnvt ff 16 2 cnvt takes value ff of base 16 and converts it to base 2. cnvt [CODE] #! /bin/sh if [ -f /usr/bin/bc ] then …

Member Avatar
Member Avatar
+0 forum 4

This is a Linux brainteaser for the C comfortable and leisurely bored. I'm not looking for the answer.. Note the compile lines are commented at the bottom of the program - Ubuntu and derivatives please use the second compile line or it will not work. So what does this program do? This program, when compiled and run, will display the addresses and values of the array myint[] plus the addresses and values of my calculated addresses...So why does this work? Why does two different memory regions appear to have the same data? Disclaimer – I can't guarantee this will work …

Member Avatar
Member Avatar
+0 forum 3

What is going on here. Copy this C code , compile and run. What do you think is going on? Note I don't want the answer, I know what's going on here. This is just something for the rookies to play with... Also this is not the best way to write code... [CODE] #include <stdio.h> #include <stdlib.h> int* myint(void) { static int myint = 9; fprintf(stdout, "myint now equals->%d\n", myint); return &myint; } int main(int argc, char**argv) { *(myint()) = 12356; myint(); exit(EXIT_SUCCESS); } [/CODE]

Member Avatar
Member Avatar
+1 forum 5

One day while pondering about C I came up with this program. Can you predict what the answer will be? Now run it, were you right? filename.c [CODE] #include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { unsigned long *iptr = (unsigned long*)0;/*pointer equals 0*/ unsigned long ans = (unsigned long)(iptr + 1);/*add 1 to the pointer*/ fprintf(stdout, "and the answer is->%lu\n", ans);/*whats the answer?*/ exit(EXIT_SUCCESS); } [/CODE] gcc filename.c -Wall -ansi -pedantic -o filename

Member Avatar
Member Avatar
+0 forum 9

Mandriva 2010 has just been released [url]http://www2.mandriva.com/downloads/[/url]

Member Avatar
Member Avatar
+0 forum 9

I wrote this very small program that works fine until I remove the comments for the fprintf function. Basically the program will prompt the user for a numeric value, when the user guesses right(1234) the program exits. When I remove the comments the program never exits...Does anyone have any idea why? I'm completely lost as to why it would behave like this...maybe its my compiler - gcc 4.4.1 [CODE] #include <stdio.h> #include <stdlib.h> unsigned long testval = 1234; void* foundit(void) { fputs("found it!\n", stdout); return (void*)0; } void* tryit(void) { unsigned long val; fputs("enter a value/guess->", stdout); fscanf(stdin, "%u", &val); …

Member Avatar
Member Avatar
+0 forum 16

The End.