Armed Polite Society
Main Forums => The Roundtable => Topic started by: zahc on April 23, 2009, 04:38:11 PM
-
I want to send text to an LCD panel. I can use an LCD library to send text and numbers (but not floats) to it. But I want to send it a double quotation mark. It's an ascii character, but I can't exactly do lcd.print("""); it's not syntactical. How can I encapsulate my " ?
-
backslash.
\"
I think that should do it.
http://richardbowles.tripod.com/cpp/cpp15.htm
-
Thanks. I thought about that, but in bash, the \ is usually used to ignore whatever comes after it.
-
Thanks. I thought about that, bit in bash, the \ is usually used to ignore whatever comes after it.
Exactly
lcd.print("\"");
lcd.print('"'); will likely work also.
as will
lcd.print(34);
:)
-
I am so happy I don't have to program anything in C++ anymore.
I had enough problems in college. All of this :
cd.print("\"");
lcd.print('"'); will likely work also.
as will
lcd.print(34);
went right through my eyes and out the back of my head.
-
Luckily I only ever need to use LabView. The joys of experimental physics. =D
-
I hate labview.
-
C++ was the state of the art when I was taking comp sci courses 15 years ago. Has nothing come along to replace it?
-
C++ was the state of the art when I was taking comp sci courses 15 years ago. Has nothing come along to replace it?
Well, there's C#, but it isn't really that widespread. C++ is still used when performance is required.
FWIW, C++ is the reason I switched my major from Computer Science to Multimedia. :lol:
Or more precisely, the guy who taught C++ is the reason. He was the type that TRIED to make you fail. Average score on his tests were in the mid 40% range. Horrible teacher - he made you actively loath the subject at the end of his class.
I still have my C++ reference manual laying around, though, along with my "C++ for dummies" book. One of these days I'll get off my ass and teach it to myself...
-
When I took programming classes at U of MO-Rolla, they were still teaching Fortran. Or was it Cobal? Anyway, I had a teacher that took off points for any mistake in a program, even a misspelling that would not affect how the program ran. He docked me one point for "its" instead of "it's". Thing is, it was the possessive "its" so it was spelled correctly.
-
C++ = B- ? ;)
-
The header file or documentation for the library should list the function declarations that exist for the .print function which will tell you what you can pass it. You've indicated it will accept a string or an integer. So you can do:
lcd.print("/""); as others have stated.
However lcd.print(34) may print out the integer 34 not the " character you want, depending on how the function's set up.
You illuded to wanting to print a float but not being able to. Since you can print a string, you can use the sprintf function to convert the float to a string. For example:
char buf[10];
float x = 1.234;
sprintf(buf, "%1.3f", x);
You could also do it using ftoa if that is implemented on your system.
-
The header file or documentation for the library should list the function declarations that exist for the .print function which will tell you what you can pass it. You've indicated it will accept a string or an integer. So you can do:
lcd.print("/""); as others have stated.
However lcd.print(34) may print out the integer 34 not the " character you want, depending on how the function's set up.
You illuded to wanting to print a float but not being able to. Since you can print a string, you can use the sprintf function to convert the float to a string. For example:
char buf[10];
float x = 1.234;
sprintf(buf, "%1.3f", x);
You could also do it using ftoa if that is implemented on your system.
Wow, it's almost like you people are speaking English.
Also, alluded, not illuded.
Hey, I may not understand any of the rest of the post, but I can fix that!
-
How can you NOT like C++? Heck, the main reason I'm working on a CompSci degree is because of how much I enjoyed the language. =D
-
C++ is still very much in use doing Real Work.
There are people out there who want to use Java for everything (and many colleges are teaching Java as a result). To be fair, Java's come a long way over its history, and it's less of a toy language than it used to be. But there are still things it can't compete with C++ on. It's also a dangerous language to teach on, because it does enough stuff for you that it breeds laziness.
C++ (and C) both have enough sharp edges and pointy bits that you learn how to be careful in ways that Java coders do not.
Right tool for the right job is what it comes down to; the system I work on uses C++ under the hood and behind the scenes, anywhere that we need high performance and/or a small footprint. We use Java for user interfaces, because it's frankly better at them (and at making them cross-platform deployable).
I'm a C++ guy, who started out as a C guy. I don't see C++ going away any time soon.
-BP
-
We do all our new development in C# where I work. As mentioned C++ is much better for performance, but C#'s benefits outweigh performance for our particular use. Unfortunately I'm currently acting as a maintenance developer, so I spend most of my time with VB6. =|
-
C++ was the state of the art when I was taking comp sci courses 15 years ago. Has nothing come along to replace it?
No. Except for maybe C, which obviously proceeded it.
There's TONS of other programming languages invented since C++. Many of them are much better than C/C++ for niches, specific tasks or every day random tasks (perl!). No single language however have come close to replacing it.
-
sprintf function to convert the float to a string.... You could also do it using ftoa if that is implemented on your system.
I'm actually programming a microcontroller using avr-gcc so I'm not sure what I have. I'm also a total programming noob. I actually wrote a function to round floats to a certain number of decimal places and display them (convert float to long, print that, print a period, multiply the original float by 10*<places>, mod<places>, print the remainder) but then I found that the LCD library actually will print floats with 2 decimal places, if you just naively pass them as if they were anything else. This is not in the docs at all and I don't know how it's implemented or if it rounds properly but it seems to be working and for display purposes I think I'll just let it do that.
-
C and C++ are still very much in use in all sorts of embedded systems in many different markets. Chances are your DVD player, cell phone, the engine computer in your car all run code written and compiled at least partially in C. I have done software development on a number of performance based embedded systems and we typically used a mix of C, C++ and assembly depending on the performance requirements, cpu speed available, and program structure.
-
How can you NOT like C++? Heck, the main reason I'm working on a CompSci degree is because of how much I enjoyed the language. =D
Like I said, it was more the professor than the language. The guy was a brilliant programmer, but he had no business teaching.
That, and I don't really have the temperament for sitting and coding all day. I'm not quite detail-oriented enough, and that's not really a good trait in a programmer.
-
Or was it Cobal?
Cobol is the devil!
Brad
-
Cobol is the devil!
Brad
No, that grants the impression that Cobol has a degree of cleverness, flexibility or a sense of humor.
No. Cobol, my friend, is the IRS.
;)
-
No, that grants the impression that Cobol has a degree of cleverness, flexibility or a sense of humor.
No. Cobol, my friend, is the IRS.
;)
:lol:
-
Devil, IRS: there's a difference?
-
Yea, you can make deals with the Devil.
-
=D