Newbie Question (take it easy on me fellas) - Creating customASCII-style characters




Please don't bite me to much with the following post, (a little
nibbling doesn't hurt though).

When I was a child I owned an Amstrad CPC6128 home computer and liked
to fiddle around with the BASIC that came with it. One of my favourite
commands was (memory permitting) something like this;

DATA xyz$ (1, 1, 1, 1, 0, etc)

this allowed you to design your own ASCII-style characters in an 8x8
gird with 1's representing a white dot and 0 not. You could then call
this as you would any other single character.

I'm currently learning C++ (albeit from a book) and was wondering if
there was a similar command for use in console style applications.

I hope that you are able to help me with this and don't bite me to
much.
Posted On: Sunday 4th of November 2012 10:30:23 PM Total Views:  187
View Complete with Replies

RELATED TOPICS OF C Language PROGRAMMING LANGUAGE




Total C newbie -- PLEASE HELP with writing a LOOP, asap!!!!

Hi , please help me out as i am a complete newbie when it comes to C programming. I have the following code (as shown below). As you can see, it is a series of if/elseif statements. I'm very much a newbie in understanding loops (I do understand them but not how I might apply them to this situation, as with loops I generally have a condition, update, etc., and other than 'times' being the update (as in number of times), I don't see how I can apply this to a loop. Basically, at the end of each of the FIRST TWO if statements, it ends in 'times=times+1' ... I just need to find a way to embed this whole thing in a LOOP so that at the end of each of these two statements, it goes back up to the "x = ..." line and begins from there again (with new values for 'guess', as assigned). Obviously, if it hits the 3rd if statement, no looping back will be necessary, so I imagine the 3rd if statement would somehow appear outside of the loop Not sure. Code: x = guess*guess - n if (|x|> tol && x>0) { tooHigh = guess; guess=(tooHigh + tooLow)/2; times= times + 1; } else if (|x|>tol && x
VIEWS ON THIS POST

174

Posted on:

Tuesday 23rd October 2012
View Replies!

newbie, C codes for linux

This is my first time in the forum so I apologize if Im not following the rules of posting. Im learning linux but this week I need to write few simple C codes and I never learned C programs. Can this forum help me Count by 1s to the number 300 each number should display as output to the screen. For each number divisible by 4 your output should reflect that number is divisible by 7. For each number divisible by 4 and 7, your output should reflect that is divisible by 4 and 7.
VIEWS ON THIS POST

180

Posted on:

Tuesday 23rd October 2012
View Replies!

algorithm copy from vector to set - newbie question

Soumen wrote: > I need to write code to copy unique elements in from a sequence > container (say vector) to a set (or another sequence container will > do). Is following code efficient A set will already contain only unique elements, so you could simply do a: uniqueSet.insert(seqContainer.begin(), seqContainer.end()); , In article , soumen78@gmail.com says... [ ... ] > Or is there a better (more efficient) way (say, some way using > lower_bound or so) to write similar functionality > Does using unique_copy over copy gives any advantage in this case Assuming your input is already sorted, there's a pretty good chance that unique_copy will give a slight performance advantage. If your input is in a vector, the memory is guaranteed to be contiguous, so it'll tend to have better locality of reference. The memory in the set will normally be in the form of noncontiguous dynamically allocated nodes. As such, traversing the identical inputs in the vector will usually be faster than in the set. OTOH, if your input is NOT already sorted, sorting it first so you can use unique_copy (meaningfully) isn't likely to work out so well. -- Later, Jerry. The universe is a figment of its own imagination.
VIEWS ON THIS POST

206

Posted on:

Saturday 3rd November 2012
View Replies!

[newbie] de-reference function

I'm wondering why the following code works just fine: #include int main() { (******printf)("!\n"); return 0; } best regards, Tony Winslow
VIEWS ON THIS POST

185

Posted on:

Sunday 4th November 2012
View Replies!

newbie question

, I'm very much (greenish) new to C++, learning it with S. Lippman's "C+ + Primer" in hand. I tried to extend one example: #include using namespace std; class IntArray { public: explicit IntArray(int sz = DefaultArraySize); IntArray(int *array, int array_size); int siz(); private: static const int DefaultArraySize = 12; int _size; int* ia; }; IntArray::IntArray(int sz) { _size = sz; ia = new int[_size]; for (int i=0; i
VIEWS ON THIS POST

177

Posted on:

Sunday 4th November 2012
View Replies!

newbie-question: networking

how can I do networking with C++
VIEWS ON THIS POST

211

Posted on:

Sunday 4th November 2012
View Replies!

newbie: Packed bitspecs?

Is there a way to do the following code so that day_data and other_data_1 occupy the same byte in memory Using the debugger, the addresses I'm getting are: 12ff5c - myVar.day_data 12ff60 - myVar.other_data_1 I'm using Microsoft Visual C++. sizeof(unsigned short) returns 2.
VIEWS ON THIS POST

168

Posted on:

Sunday 4th November 2012
View Replies!

questions about data strcuture

I am currently developping a software where items that will be inserted into a graphical widget ListCtrl are first defined in static array as shown below : enum TUiContext { EUiContextMain = 0, EUiContextSchedule, EUiContextSettings, EUiContextSubscription, EUiContextCount }; typedef struct { int TextId; int ImgId; int Param; int nOptInfo; TCHAR szImgName[MAX_PATH]; } ListInfo_t, *LPListInfo_t; ListInfo_t CMainView::ms_listInfo_Main[]= { // String ID, Img, Param = CmdBarId Enabled ImgName { IDS_MENU_BACKUP, 0, IDM_MENU_CMDBAR_BACKUP, TRUE, _T( "" ) }, { IDS_MENU_SCHEDULE, 2, IDM_MENU_CMDBAR_OPTIONS, TRUE, _T( "" ) }, { IDS_MENU_RESTORE, 1, IDM_MENU_CMDBAR_RESTORE, TRUE, _T( "" ) }, { IDS_MENU_MANAGE_SUBSCRIPTION, -1, IDM_MENU_MANAGE_SUBSCRIPTION, TRUE, _T( "Menu_Account_Manage.png" ) }, }; ListInfo_t CMainView::ms_listInfo_Options[]= { // String ID, Img, Param = CmdBarId { IDS_MENU_FREQUENCY, 0, IDM_MENU_SCHEDULER, TRUE, _T( "" ) }, { IDS_MENU_CONTENT, 1, IDM_MENU_SELECTDB, TRUE, _T( "" ) }, }; .... Actually in functions of some parameters, some items won't be inserted and the field nOptInfo is used for this purpose. If this field equals 1 it will be inserted into the List. So I have a method called InitResources that check the config parameters and update nOptInfo for each array. Once this has been done, I build a vector as shown below : void CMainView::InitResources() { std::vector vecListInfo; std::map listMap; // Test config parameters and update nOptInfo ... //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Now build vector from ms_listInfo_Main //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ vecListInfo.clear() for (int i = 0; i < _countof(ms_listInfo_Main); i++) { if (ms_listInfo_Main[i].nOptInfo == TRUE){ vecListInfo.push_back(ms_listInfo_Main[i]); } } listMap[ EUiContextMain ] = vecListInfo; //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Now build vector from ms_listInfo_Options //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ vecListInfo.clear() for (int i = 0; i < _countof(ms_listInfo_Options); i++) { if (ms_listInfo_Options[i].nOptInfo == TRUE){ vecListInfo.push_back(ms_listInfo_Options[i]); } } listMap[ EUiContextSchedule] = vecListInfo; ... } I find all this code very ugly and I would like to suggestion to improve it. I am doing all this because I am switching between different graphical context and before to do it I save the index of current selected item in my ListCtrl.
VIEWS ON THIS POST

118

Posted on:

Sunday 4th November 2012
View Replies!

Re: const auto_ptr member question

On Nov 20, 10:50 am, jtorjo2...@yahoo.com wrote: > > A a1; > > A a2 = a1; //COMPILES with g++ > > A a3(a1); //COMPILES with g++ > > g++ is wrong. VS2005 and comeau (http://www.comeaucomputing.com/ > tryitout/) both give compile errors > > What version of g++ gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Joel Eidsath -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
VIEWS ON THIS POST

101

Posted on:

Sunday 4th November 2012
View Replies!

two interesting data structure/algorithm questions

First of all, sorry for cross posting. Couldn't find a dedicated newgroup for this. My friend asked me two questions about data structure and algorithms. I think she got them from some job interview books. I felt they are interesting but haven't found good solutions yet. Could someone give some suggestions Q1: Suppose you are looking up a contact name on your cell phone's address book. Suppose your contact's name is "abc123". Then you type "a" in the search box. The cell phone shows all names start with letter "a" in sorted order. Then you type "b" after the first "a". The cell phone shows all names start with letters "ab" in sorted order. Then you type "c" after the "ab" and the cell phone shows all names starts with letters "abc" in sorted order. You keep typing the contact name and the list shown by your cell phone keeps updating and shrinking untill at last either you find your contact name or you don't. Question: what's the best data structure and algorithm to implement this real-time lookup effeciently and what's the time complexity of the implementation Q2: Suppose you have a book written in English. Your goal is to search for an arbitrary string and return the page numbers where this string is found. There could be more than one page number returned if the string is cross page or if it's found on multiple pages. For example, you have a string "this is an " on page 20 and then " interesting book" on page 21. The string you are going to search for could be "this" or "this is" or "is an" or " an interesting" or "an interesting book". Then you'll need to return page numbers [20], [20], [20], [20,21], [20,21] respectively. Of course, if you look for "book", it could return hundreds of page numbers since "book" is really common. Question: what's the best data structure and algorithm to implement this real-time lookup effeciently and what's the time complexity of the implementation I can think out using hashes but since the string to look up can be arbitrary, the hash table will be huge...
VIEWS ON THIS POST

140

Posted on:

Sunday 4th November 2012
View Replies!

Strange questions about : int atoi(const char *nptr);

Strange questions about : int atoi(const char *nptr); in ISO C standard. I just wonder what does "n" stands for in "nprt" "atoi" can be dissected as "Ascii TO Integer" "ptr" stands for PoinTeR then, what does "n" stands for THANKS! -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] , Visame wrote: > Strange questions about : int atoi(const char *nptr); in ISO C > standard. > > I just wonder what does "n" stands for in "nprt" > > "atoi" can be dissected as "Ascii TO Integer" > "ptr" stands for PoinTeR > > then, what does "n" stands for > > THANKS! > Perhaps "numeric" -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
VIEWS ON THIS POST

129

Posted on:

Sunday 4th November 2012
View Replies!

question - using boost::bind

, i've a question related to bind and the use of function-objects that "point" to an overloaded member-function. look at this example: class foo { public: const foo& operator= (int); }; with boost::bind i can create a function object pointing to the operator= of a specific object: foo arg; x = bind(&foo:perator=,ref(arg),_1); now: x(1); is like : arg = 1; Thats very nice for me - but the problem occur when i overload operator= . For example: class foo { public: const foo& operator= (int); const foo& operator= (const foo&); }; Now the bind doesnt work anymore: error message: "unresolved overloaded function type" Well, thats comprehensible for me - but i am asking myself if there is a way to tell the compiler which of these function he should us Is it possible, or do you know a work-around
VIEWS ON THIS POST

131

Posted on:

Sunday 4th November 2012
View Replies!

name lookup question ("gotw 30")

, I looked at this example while trying to understand name lookup : http://www.gotw.ca/gotw/030.htm . (It is also present in this book - "More exceptional c++") As per the article, the recursive call to foo() below at line marked with "//1" should be ambiguous. However, it is not. It always invokes N2::foo leading to infinite recursion. Further, if I replace "using namespace N1" with "using N1::foo" , then it will call N1::foo . As per the article, this too should be ambiguous. Is it a compiler bug (vs 2008 and gcc 4.1) or am i misunderstanding the article
VIEWS ON THIS POST

89

Posted on:

Sunday 4th November 2012
View Replies!

beginner's question on slicing

In his book, Stroustrup has mentioned that slicing can be a source of surprises and errors. I am unable to understand it. Kindly give an example where slicing can lead to surprise and error.
VIEWS ON THIS POST

144

Posted on:

Sunday 4th November 2012
View Replies!

question on list

For vector and deque, the memory layout may be contiguous in which case we cannot have array of references and so we cannot have vector and deque. Am I correct However I am unable to create list c; Though 'list' does not involve contiguous memory layout, the above is disallowed because we cannot reseat a reference(in the sense that we cannot rebind a reference to a different object through assignment operator). Is the reasoning correct; or is there some other reason for disallowing list of references. Kindly clarify.
VIEWS ON THIS POST

200

Posted on:

Sunday 4th November 2012
View Replies!

question concerning realloc

I have an application (written in C) that requires me to read through a null-terminated string and potentially drop certain characters, replace characters with other characters and finally replace substrings with other strings. Additionally while the size of the original string is known at runtime, the size of the resulting string is unknown initially. So, my thought would to allocate an initial buffer (of some size) and start copying into it. When the buffer is almost full (i.e. has one byte left) use realloc to enlarge the buffer an keep copying. However I getting a segmentation fault, along with the error: realloc() : invalid next size Searching google for that error message, while providing a significant number of hits hasn't proved useful (or else I'm just to tired to comprehend what I'm reading) I have written a small program that demonstrates this behavior and have included its output as well. Any insight would be greatly appreciated. Script started on Tue 23 Oct 2007 05:30:10 PM EDT $>more test_realloc.c #include #include #include #define BASE_SIZE 8 #define INC_SIZE 4 char src[]={'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\0'}; char* doCopy(char*, char**); int main() { char* buf = NULL; printf("%s", doCopy(src, &buf)); return 0; } char* doCopy(char* src, char** dst) { int ndx = 0; int maxSize = BASE_SIZE; char* ptr = src; /* clear output array, if there is any data there..... */ if(NULL != *dst) { free(*dst); *dst = NULL; } /* create the initial output array....*/ *dst = malloc(sizeof(char) * BASE_SIZE); memset((void*)*dst, '\0', BASE_SIZE); while(*ptr) { if(strlen(*dst) == (maxSize - 1)) { char* temp = NULL; maxSize += INC_SIZE; fprintf(stdout, "In growth step..(%s)..new size will be %d\n", *dst, maxSize); if(NULL == (temp = realloc(*dst, INC_SIZE))) { fprintf(stderr, "realloc failed...aborting\n"); free(*dst); exit(1); } else { *dst = temp; memset(&((*dst)[ndx+1]), '\0', INC_SIZE); } } (*dst)[ndx++] = *ptr; ++ptr; } return *dst; } $>gcc -ansi -pedantic -Wall -g test_realloc.c -o test_realloc $>./test_realloc In growth step..(ABCDEFG)..new size will be 12 In growth step..(ABCDEFGHIJK)..new size will be 16 In growth step..(ABCDEFGHIJKLMNO)..new size will be 20 *** glibc detected *** ./test_realloc: realloc(): invalid next size: 0x092dd008 *** ======= Backtrace: ========= /lib/libc.so.6[0x6c881b] /lib/libc.so.6(__libc_realloc+0xf1)[0x6ca639] ../test_realloc[0x8048624] ../test_realloc[0x804852f] /lib/libc.so.6(__libc_start_main+0xdc)[0x6787e4] ../test_realloc[0x8048481] ======= Memory map: ======== 0038e000-0038f000 r-xp 0038e000 00:00 0 [vdso] 00642000-0065b000 r-xp 00000000 03:05 10935406 /lib/ld-2.4.so 0065b000-0065c000 r-xp 00018000 03:05 10935406 /lib/ld-2.4.so 0065c000-0065d000 rwxp 00019000 03:05 10935406 /lib/ld-2.4.so 00663000-0078f000 r-xp 00000000 03:05 10935407 /lib/libc-2.4.so 0078f000-00792000 r-xp 0012b000 03:05 10935407 /lib/libc-2.4.so 00792000-00793000 rwxp 0012e000 03:05 10935407 /lib/libc-2.4.so 00793000-00796000 rwxp 00793000 00:00 0 00a5a000-00a65000 r-xp 00000000 03:05 10935412 /lib/libgcc_s-4.1.0-20060304.so.1 00a65000-00a66000 rwxp 0000a000 03:05 10935412 /lib/libgcc_s-4.1.0-20060304.so.1 08048000-08049000 r-xp 00000000 03:02 1966089 /home/ghuber/junk1/test_realloc 08049000-0804a000 rw-p 00000000 03:02 1966089 /home/ghuber/junk1/test_realloc 092dd000-092fe000 rw-p 092dd000 00:00 0 [heap] b7e00000-b7e21000 rw-p b7e00000 00:00 0 b7e21000-b7f00000 ---p b7e21000 00:00 0 b7f50000-b7f51000 rw-p b7f50000 00:00 0 b7f6c000-b7f6e000 rw-p b7f6c000 00:00 0 bfd59000-bfd6e000 rw-p bfd59000 00:00 0 [stack] Aborted (core dumped) exit Script done on Tue 23 Oct 2007 05:30:58 PM EDT
VIEWS ON THIS POST

112

Posted on:

Sunday 4th November 2012
View Replies!

question about template specialization

Hi , I'm having trouble understand result of the following simple case. Can someone help explaining what's going on there
VIEWS ON THIS POST

129

Posted on:

Sunday 4th November 2012
View Replies!

object assignment/initialisation question

On Oct 18, 10:03 pm, Anonymous wrote: > Just need to clarify the order at which assignement takes place > > int main(int argc, char* argv[]) > { > A a ; // default ctor > A b(a) ; // copy ctor > A c = b ; // default ctor THEN assignemnt OR copy ctor \t copy constructor. A c; c = b; // copy assignment operator -N , > OT: > I am using the clunky MSVC IDE, so am unable to quickly compile and test > this (without creating a project in the IDE) - incidentally, if anyone > knows how to compile litle code snippets like this using a command line > compiler that runs on Windoze (possibly the VC complier) - without > needing invoking the IDE/ requiring a project etc, ala gcc - please post > instructions etc, so in future I can carry out such tests myself ) I would recommend getting to know MSVC a little better. It's actually not very difficult to create a little test program like this. Just create a new "console application" and in the advanced setting make it an "empty project". Much faster than posting to a group like this. Plus, you get the full use of the debugger.
VIEWS ON THIS POST

121

Posted on:

Sunday 4th November 2012
View Replies!

const or not const, that's the question here! :-)

The compiler which I have to use in a project doesn't like the following construct. It says: 'bitset' : invalid template argument. It means that it wants only a static-like const N as a template argument, ie. it doesn't accept a const variable that was initialized from an auto variable (here i), for passing it as a template argument to bitset. Is this a compiler limitation or is my code not standard conform Can you think of any workaround construct to achieve this or an alternate functionality with such a compiler Of course if I change the line to read for example const size_t N = 1U
VIEWS ON THIS POST

120

Posted on:

Sunday 4th November 2012
View Replies!

Compiler question...

What is the best compiler to use regarding C++\t -- --------------------------------- --- -- - Posted with NewsLeecher v3.9 Beta 8 Web @ http://www.newsleecher.com/usenet ------------------- ----- ---- -- - -- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com
VIEWS ON THIS POST

120

Posted on:

Sunday 4th November 2012
View Replies!