|
Strange MV C++ error in dev-c++.. |
Albin Engström
Member #8,110
December 2006
|
Ok, im still working on my "write a string with my bitmaps function" but when i got too the part where i was going to use the string.at(pos) function, i get a strange error saying: Runtime Error! This application has requested the Runtime to terminate it in an unusual way. first: this error was kinda unexpected since i really followd how to use strings.. but i guess i did not follow the instuctions too well, as i never do. second: WHAT SUPPORT TEAM?? how do i change this? becouse i don't like it when my app says things for me.. and this error was an microsoft visual c++ error.... where did that came from? the string library? here's the code. noc = text.txt[txtstring].length(); |
Elverion
Member #6,239
September 2005
|
Would it kill you to use capitalization, spell check, and code tags? noc = text.txt[txtstring].length(); for(nr1 = noc; nr1 > 0; nr1--) { if( text.txt[txtstring].at(1) == ' ' ) bax++; } It looks like you were using txtstring's length for whatever was in position 1 in text.txt, which may or may not have existed. I'm not sure if that was supposed to be like that or not without more code, but to me, it looked like an error. -- |
Albin Engström
Member #8,110
December 2006
|
No, not really, but i don't know how too use code tags (because i did not care about it). but i will probably use it in the future. the txtstring is a value i use to get a string from text.txt[] if( text.txt[txtstring].at(1) == ' ' ) should actually be if( text.txt[txtstring].at(nr1) == ' ' ) but it does not matter in this case.(i guess?). i'm sorry that i can't give you more code, i've seen other people posting there codes and they end up having corrections for everything but the problem they was asking about ^^'.. so i minimize this possibility by not posting my whole code. |
Elverion
Member #6,239
September 2005
|
Hmm, well, I can understand why some people (especially new programmers) are embarrassed to show their messy code, but it is for the best. It is better to get those conventions down now while you are still learning, rather than struggle with them later on. What exactly are you trying to do? Just count the number of spaces in a string? unsigned int SpacesInString(std::string input) { unsigned int count = 0; for(unsigned int i = 0; i < input.length(); i++) { if( input<i> == ' ' ) count++; } return count; } Then just call bax = SpacesInString( text.txt[txtstring] ). You get the idea at least. I think it is easier, and more logical, to read the characters from 0 to length, but if you prefer to do it the opposite way, that's fine too. -- |
Albin Engström
Member #8,110
December 2006
|
, Sorry if i have confused you with my bad explanation of what I'm trying to do, i will try to give you a more detailed description. i have a function called "write" to which i send the folling data, this function then draws the string(WILL draw), within the box. void write(BITMAP *b, int txtstring, int posX, int posY, int hight, int width) anyway: as i'm new to almost everything out there i always test things before using the only thing i was hoping for was a valid code, but that strange error showed besides, this microsoft visual c++ thing really scares the shit out of me.. (i did not use code tags again, because i don't think of that as code..) |
BAF
Member #2,981
December 2002
|
Quote:
i'm sorry that i can't give you more code, i've seen other people posting there codes and they end up having corrections for everything but the problem they was asking about ^^'.. so i minimize this possibility by not posting my whole code. Well, our corrections are to help show you potential bad practices or flaws in your code. You really shouldn't be embarrassed about your code. Quote:
besides, this microsoft visual c++ thing really scares the shit out of me.. What? What the hell are you talking about... what is a microsft stained application? As far as helping you with this problem, I don't really get what the problem is and what you are doing and why you are doing it. |
Albin Engström
Member #8,110
December 2006
|
Well, mainly, i'm not experienced enought to take in everything everyone says, therefor i try to avoid advanced talk... personally i think i described pretty well what im trying to do . I'm trying to make a function for drawing text on the screen, THE END. . ok, i freaked out when my app made the word "microsoft". i don't expect you too understand my feelings .. i've added an attachment, it's a picture of armageddon. |
BAF
Member #2,981
December 2002
|
That's just because you are using the MS runtime (which you can't really avoid on Windows) and your program is crashing. As far as drawing text, what's wrong with textprintf_ex or textout_ex? |
Elverion
Member #6,239
September 2005
|
Also, shouldn't '' be '\0' for the NULL character (I think that's what you were checking for)? I don't understand why you would want to do that though...it would occur at whatever length() returns. Exactly how does putting text onto the screen relate to the code you've shown? I guess you are trying to use these strings to format it in some way, but I don't see how it relates to your code. Can you give us an example of what one of these strings should look like, and how you would like it to be used (in code)? -- |
Albin Engström
Member #8,110
December 2006
|
, as i said, the code i wrote was only written as a test, it has nothing to do with writing a string on the screen, but i'm glad that i did not write it because i can't use the .at() string command. Do i have to use the MS runtime? :/ are you saying that ' ' is the same thing as ''? and that '\0' is for the NULL character? (is that the blankspace?). It seems that was not the case, as it still does not work. |
LennyLen
Member #5,313
December 2004
|
Quote: Do i have to use the MS runtime? On MS Windows, yes. Quote: are you saying that ' ' is the same thing as ''? and that '\0' is for the NULL character? ' ' is not the same as ''. ' ' is the blankspace character. '' is an empty character constant. You should get compiler errors if you try to use ''. Yes, '\0' is the NULL character.
|
Tomasz Grajewski
Member #4,284
February 2004
|
Quote:
to give the text display a nice look i decided to make an extra piece of code, I think, that You are talking about word wrapping. I'm right? If yes, then I have a such function, which prints text to a bitmap with word wrapping (and if it isn't possible, then with character wrapping). I hope that it will be useful to You
___________________________________________________________________________________________ |
Albin Engström
Member #8,110
December 2006
|
LennyLen: Noted. Tomasz Grajewski: I don't use fonts, i use bitmaps. but thanks anyway . |
BAF
Member #2,981
December 2002
|
What? WHY don't you use fonts? |
Albin Engström
Member #8,110
December 2006
|
Because fonts don't look as good as bitmaps. . |
LennyLen
Member #5,313
December 2004
|
Quote: Because fonts don't look as good as bitmaps. So create a font from your bitmaps then.
|
Thomas Fjellstrom
Member #476
June 2000
|
Not sure if you're aware Albin, but allegro's fonts support bitmapped true colour "fonts". As well as the normal mono fonts. -- |
Albin Engström
Member #8,110
December 2006
|
... you're kidding, right? ><. That's so annoying.. but good, so how do i use this feature? |
Thomas Fjellstrom
Member #476
June 2000
|
You create a image with the font characters you want, and import via the grabber as a FONT object, then you load the created datafile when you load your program, and theres your font. -- |
Albin Engström
Member #8,110
December 2006
|
Nice, but isn't there like a guide line for how i should put the bitmaps(in the bitmap) in order to get a valid font? |
|