Tuesday, March 1, 2011

Printing funky text using C program part 1

Author: Joe Patner:dvd ripper

 

Ladies and gentlemen, I give you the following: Ta da!  I am a text string.

It’s a simple collection of text, numbers, letters, and other characters — but it’s not a string of text. Nope. For those characters to be considered as a unit, they must be neatly enclosed in double quotes:
“Ta da!  I am a text string.”

Now you have a string of text, but that’s still nothing unless the computer can manipulate it. For manipulation, you need to wrap up the string in the bunlike parentheses: (“Ta da!  I am a text string.”)

Furthermore, you need an engine — a function — to manipulate the string. Put printf on one side and a semicolon on the other:
printf(“Ta da!  I am a text string.”);

And, you have a hot dog of a C command to display the simple collection of text, numbers, letters, and other characters on the screen. Neat and tidy.

Consider this rabble:  He said, “Ta da! I am a text string.”

Is this criminal or what? It’s still a text string, but it contains the double-quote characters. Can you make that text a string by adding even more double quotes? “He said, “Ta da! I am a text string.””

Now there are four double quotes in all. That means eight tick marks hovering over this string’s head. How can it morally cope with that?
“”Damocles” if I know.”

The C compiler never punishes you for “testing” anything. There is no large room in a hollowed-out mountain in the Rockies where a little man sits in a chair looking at millions of video screens, one of which contains your PC’s output, and, no, the little man doesn’t snicker evilly whenever you get an error. Errors are safe! So why not experiment?

 

Welcom to reproduce this passage. Please indicate the source.
Source:Seo Research Blog
Links resources:dvd to flv 

Printing funky text using C program part 2

Please enter the following source code, DBLQUOTE.C. The resulting program is another “printf() displays something” example. But this time, what’s dis­played contains a double quote. Can you do that? This source code is your experiment for the day:
#include <stdio.h>
int main()
{
printf(“He said, “Ta da! I am a text string.””);
return(0);
}

Type the source code exactly as it appears, including the double quotes — four in all. (You notice right away that something is wrong if your editor color-codes quoted text. But work with me here.)

Save the source code file to disk as DBLQUOTE.C. Compile and run the preceding program — if you can. Chances are that you encounter one of these errors instead:

dblequote.c: In function ‘main’:
dblequote.c:5: parse error before “Ta” or
dblequote.c: In function ‘main’:
dblequote.c:6: syntax error before “Ta”

The printf() function requires a text string enclosed in double quotes. Your compiler knows that. After the second double quote in the string was encoun­tered (before the word Ta), the compiler expected something else — something other than “Ta.” Therefore, an error was generated.

Obviously, there is a need to use the double-quote character in a string of text. The question is how to pass that character along to printf() without it ruin­ing the rest of your day. The answer is to use an escape sequence. In the olden days, programmers would have simply gone without certain char­acters. Rather than trip up a string with a double quote, they would have used two single quotes. Some ancient programmers who don’t know about escape sequences still use these tricks.

 

Welcom to reproduce this passage. Please indicate the author and the source.
Author: Joe          Source:Seo Research Blog
Partner:dvd to flv  converter from dvd ripper

Friday, February 18, 2011

Breaking up lines\ is easy to do part3

Author: Joe
Partner: dvd ripper

To wit, change Lines 10 and 11 in the source code from this:


printf(“C is done mostly in lowercase.\
It’s a case-sensitive language.”);

to this:
printf(“C is done mostly in lowercase. \
It’s a case-sensitive language.”);


Note the extra space after the period in the first line (before the backslash), which keeps the two lines of text from running into each other. Save that mess. Compile and run. The output shall be most pleasing to the eye.


Do note that some programs elsewhere in this book may use the \ to split long lines.


Don’t worry about using the \ to split any lines. It’s a trick you see others use occasionally, but in my travels I prefer using a sideways-scrolling editor to splitting up long lines.


Although split lines are treated as a single line, any errors that happen on either line are given their proper line number in the source code file. So, if a semicolon were missing at the end of Line 11 in the RULES.C example, the compiler would flag it on that line, not on the line before it.

See also:

http://clanguage86.blogspot.com/2011/01/four-steps-to-build-c-program.html

http://clanguage86.blogspot.com/2011/01/5-steps-to-reedite-your-c-source-code.html

http://clanguage86.blogspot.com/2011/01/what-meaning-of-recompiling-c-program.html

Breaking up lines\ is easy to do part2

Author: Joe
Partner: dvd to mp3

 

Depending on how your editor and compiler behave, the result of splitting a line with a string of text in it may not be what you want. For example, the output on your screen may look like this:


Braces come in pairs!
Comments come in pairs!
All statements end with a semicolon!
Spaces are optional!
Must have a main function!
C is done mostly in lowercase.  It’s a case-
sensitive language.


That happens because the split line includes a few tabs to indent things - which looks pretty in your source code, but looks like blech when the pro­gram runs. The solution is merely to edit the source code so that the extra tabs are removed from the string of text.

 

See also:

http://clanguage86.blogspot.com/2011/01/compiler-and-linker.html

http://clanguage86.blogspot.com/2011/01/how-to-compile-goodbyec.html

http://clanguage86.blogspot.com/2011/01/extra-help-in-typing-goodbyec-source.html

Breaking up lines\ is easy to do part1

Author: Joe
Partner: dvd to mp3

 

Another anomaly of the RULES program is that rogue \ character found at the end of the tenth line. When used to end a line, the sole \ tells the compiler that the rest of the line is merely continued on the line that follows. So, these two lines:


printf(“C is done mostly in lowercase\
It’s a case-sensitive language.\n”);


are both seen as one single line when it comes time to compile; all the compiler sees is this:

printf(“C is done mostly in lowercase It’s a case-sensitive
language.\n”);

You may find such a trick necessary for extra-long lines as your programs grow
more complex. The \ simply lets you split up a long line between several lines
in your source code. That can be handy.

 

See also:

http://clanguage86.blogspot.com/2011/01/source-file-and-goodbyec-practice.html

http://clanguage86.blogspot.com/2011/01/c-development-cycle-and-c-programmer.html

http://clanguage86.blogspot.com/2011/01/stuff-you-dont-need-to-know-about.html

Friday, February 11, 2011

6 unkonwn C language components

The C language has many other parts, making it look rather bizarre to the new programmer. Right now, all that’s standing between ignorance and knowledge is time, so don’t dwell on what you don’t know. Instead, keep these few points rolling around in your mind, like so many knowledge nuggets:

The C language uses words — keywords, functions, and so forth — as its most basic elements.

Included with the words are symbols. Sometimes these symbols are called operators, and at other times they’re called something else. For example, the plus sign (+) is used in C to add things.

The words have options and rules about how they’re used. These rules are all referenced in the C reference material that came with your compiler. You don’t have to memorize all of them, though a few of them become second nature to you as you study and use C.

Parentheses are used to group some of the important items required by C words. The words are put together to create statements, which are similar to sentences in English. The statements all end with a semicolon.

Braces are used to group parts of a program. Some words use braces to group their belongings, and all the separate functions you create within a program are grouped by braces. The braces have been used to con­tain the belongings of the main() function.

All this stuff put together (and more stuff I dare not discuss at this point) makes up the syntax of the C language. Syntax is how languages are put together.

Passage reproduced from:http://clanguage86.blog.co.in/2011/02/11/6-unkonwn-c-language-components/

See also:

The Four Steps to build a C program

5 steps to reedite your C source code file

What's the meaning of recompiling the C program?

Sponsor:DVD Rippers

5 quizzes about C language! Take the challenge!

Hey, guys, here are 5 quiz about C language, normally 90% of people that take the quiz beblow can only get 4 of them right. Out of another 10%, there are only less than 5% can get them all right. Take the challenge and see if you can get them all right. Good luck.

1.  The core function in every C language program is called
A. numero_uno().
B. main().
C. primus().
D. core().


2.  C language keywords are
A. The “words” of the C language.
B. Held together with string and earwax.
C. Uttered only in candlelit reverence by the C Language Gurus.
D. As numerous as the stars and nearly as distant.


3.  In addition to keywords are
A. Functions, such as printf().
B. Operators, such as +, -, and other weird things.
C. Curly braces or brackets, angle brackets — all sorts of brackets. Man, do we have a bracket problem!
D. Probably all of the above.


4.  Functions require parentheses because
A. They talk in whispers.
B. The parentheses keep the function warm.
C. The parentheses hold various things required by or belonging to the function.
D. What’s a function?


5.  A telltale sign of any C program is its curly braces. Using what you know of
C, draw in the braces where they should appear in the following program:
int main()
printf(“Goodbye, cruel world!\n”);
return(0);

I will give the answers in later post of this blog. So keep an eye on this blog.

Passage reproduced from:http://clanguage86.blog.co.in/2011/02/11/5-quizzes-about-c-language-take-the-challenge/

See also:

What to do when you come across an error?

The autopsy Part1

The autopsy Part2

Sponsor:DVD Ripper