Knowing the function printf

I found here in the texts by missing directories my partition ~ / I found this very interesting text about the printf function, correct the errors of Portuguese and I'm posting it.


################################################## #
# # # Printf Detailing # # #
################################################## #

made by Blood_Sucker!

NOTE: This text eh for the newbie community on the planet, so if you think you're elite, you will not see anything good here.

============
Summary |
============

1. Introduction
2. Understanding printf
3. Escape characters defined by C
4. Breaking a string of characters in two lines
5. Determining the number of characters that printf printed
6. Showing values of type int using printf
6.1. Printing formatted integer
6.1.1. Shifting the right impression
6.1.2. Preceding zeros of a shift
6.2. Printing an integer value Octal or Hexadecimal
6.3. Printing a prefix before the octal values or Hex
6.4. Printing values of type unsigned int using printf
6.5. Printing values of type long int using printf
7. Printing of float values using printf
7.1. Printing of float values in exponential format
7.2. Printing values of type float in other ways
7.3. Printing formatted float values
8. Printing values of type char using printf
9. Printing a string of characters using printf
9.1. Printing a string type Near and Far
10. Printing an address of a pointer using printf
11. Printing something preceded by a plus or minus
12. ANSI
12.1. Using the ANSI driver to clean your screen (clear)
12.2. Using the ANSI driver to display the colors of the screen
12.3. Using the ANSI driver to position the cursor
13. Administrivia

1. Introduction
=============

Well friends, I've been reading some things about C but had never found the net, and absolutely loved to write in detail about the printf function of the C programming language, although q be a simple function to print the screen contains various tricks to use it, thereby gaining time and space in code of course, wiping your code even more you will have a faster processing and such ... Despite all this, this text is merely a basic guide on this feature in order to understand the same, just a very basic knowledge of C and have notions about data types decimal, hexadecimal, binary and octal. But nothing so difficult. It is a text beeeem idiot, but can be useful for those who are beginning, and for those who already know, because although simple, has a lot detalhezinhos I never found the net =]
And in the end I teach to handle ANSI color and tals ... Several friends did not know my q just could not do that. And as Nash says, we are all newbies, we have much to learn. You may be thinking I'm an idiot who just wants to write one of these ridiculous textinho me out saying "ohh, I wrote to unsekurity. If you think this guy, okay, I think the same. But it has nothing to do. I contribute to what can I.

Read more ...

Share:
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Rec6
  • Slashdot
  • FriendFeed
  • Digg
  • Print
  • PDF
  • email
  • Add to favorites

Problems with scanf + strings? Here the solution

Some people have a problem with the use of scanf, especially in the use of spaces in the strings, to resolve this has a very simple trick. Let the code below:

#include<stdio.h>
int main()
{
char frase[50];
printf("Digite a uma frase: ");
scanf("%s",frase);
printf("A frase digitada foi: %s\n");
return 0;
}

Compile: gcc frase.c -o frase

Result:

bash-3.1$ frase
Digite a uma frase: joao caiu feio
A frase digitada foi: joao
bash-3.1$

To resolve this problem scanf not capturing the rest of the sentence using the parameter% [^ \ n] instead of% s, for example:

#include<stdio.h>
int main()
{
char frase[50];
printf("Digite a uma frase: ");
scanf("%[^\n]",frase);
printf("A frase digitada foi: %s\n");
return 0;
}

Compile: gcc frase2.c -o frase2

Result:
bash-3.1$ ex6
Digite a uma frase: joao caiu feio
A frase digitada foi: joao caiu feio
bash-3.1$

Now the phrase was properly captured, to avoid overflows in the use of this parameter in the scanf, placing limit% [^ \ n], and ceiling equal to the maximum amount of characters that scanf will store the variable. Staying that way.

#include<stdio.h>
int main()
{
char frase[50];
printf("Digite a uma frase: ");
scanf("%49[^\n]",frase);
printf("A frase digitada foi: %s\n");
return 0;
}

To clear the buffer after the use of scanf with this parameter, use getchar() after scanf.

#include<stdio.h>
int main()
{
char frase[50];
printf("Digite a uma frase: ");
scanf("%49[^\n]",frase);
getchar();
printf("A frase digitada foi: %s\n");
return 0;
}

I hope that this will serve to be able to solve their problems using scanf and strings. Good education at all. In the references have a link with a table stating a series of interesting parameters for the use of scanf, the second link has an article with tips for printf and scanf the dynamic duo.

Reference:

Using scanf () for strings with spaces
Interesting parameters of scanf and printf in C

Share:
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Rec6
  • Slashdot
  • FriendFeed
  • Digg
  • Print
  • PDF
  • email
  • Add to favorites
Tags: , , Categories: Programming Tags:

FLISOL 2010 DF

Participation in the 2010 FLISOL Brasilia is completely free and will be certified. To participate simply heading to the venue (FAJESU) on 24 April 2010, from 08:00 to 18:00, if desired, with your computer to install free software all day event.

If you do not take your computer to install free software, you can still participate by watching lectures, mini-course is interacting with other visitors and users of free software.

Bring your family and friends alike to learn more about the free software and to exchange experiences of the free world, whether you are a User with any level of knowledge.

You can participate in three ways:

  • As speaker, trainer of mini-courses of the event until the 10th of April 2010. In this case just download the application form of activity and send to e-mail Organization Event organizacao@flisoldf.blog.br with the subject "Call for Papers - FLISOL DF-2010.
  • GUIDE How to watch and participate in activities, lectures and mini-courses. Register for the event by visiting the REGISTRATION FLISOL DF-2010 (Click here).
  • How SPONSOR (either an individual or company) or as a participant in organizing the event, please contact the organization via telephone: (61) 9176-6393 or by e-mail: organizacao@flisoldf.blog.br

Banner do evento FLISOL 2010.

Come join!

More Info.

Share:
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Rec6
  • Slashdot
  • FriendFeed
  • Digg
  • Print
  • PDF
  • email
  • Add to favorites
Tags: , , Categories: Events Tags:

[Tool] IntensiveDos

Excellent tool, open source, published by Lucas Fernando Vasconcelos de Arruda Amorim

IntensiveDos is a tool for DoS pentesting with it is very easy to know how your server responds and catalogs attacks gender. It is a very simple and free of any specific protocol.

The flow of the thread is quite simple: Open Connection> Write> Close Connection. If you need something more specific, feel free to change the source.

If you open many threads we recommend downloading the stack size, make a very simple command:

$ ulimit -s 400 (the lower more threads)

Code below.

Read more ...

Share:
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Rec6
  • Slashdot
  • FriendFeed
  • Digg
  • Print
  • PDF
  • email
  • Add to favorites

Flisol 2010 - Vitória / ES

24/04 - Flisol 2010 - Vitória / ES

The FLISOL 2010 will take place on 24/04 in the miniauditório FAESA - Campus 1, Rua Anselmo Serrat, n.199, near Victoria Av Marechal and Campus in the district of Santa Maria Island in Vitória, ES.

Banner do evento Flisol 2010 - Vitória/ES

The schedule:

08:40 H - 09:00 am - Registration and receipt of donations
09:00 - 09:40 h - Lecture 1: Linux distributions [Almir Mendes]
09:40 h - 10:20 h - Lecture 2: Gentoo Linux [Raphaela Marques Rocha]
10:20 - 11:00 - Lecture 3: Arch Linux [Albino Biasutti Neto]
11:00 h - 11:40 h - Lecture 4: CentOS Linux [Rodrigo Griffo]
11:40 h - 12:20 h - Lecture 5: Social Entrepreneurship and Free Software [Cristiano Vitorino]

Entry: 1kg of non-food precível

More information.

Share:
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Rec6
  • Slashdot
  • FriendFeed
  • Digg
  • Print
  • PDF
  • email
  • Add to favorites
Powered by SEO Platinum SEO from Techblissonline