answersLogoWhite

0

Syntax:

==========================================

==========================================

Suppose you want to print a Character for 50 (or so) Times before entering Main ().

Here the code goes:

#include "stdio.h"

#include "conio.h"

void PrintChars ()

{

char cChar;

int iTimes, iLoop;

printf ("\n Enter a Character to print: ");

scanf ("%c", &cChar);

printf ("\n How many times you want \'%c\' to print", cChar);

scanf ("%d", iTimes);

for ( iLoop=1; iLoop <= iTimes; iLoop++)

printf ("%c", cChar);

}

#pragma startup PrintChars

void main ()

{

printf ("Entering Main()...\n");

getch();

printf ("Exit from Main()...\n");

getch();

}

User Avatar

Wiki User

∙ 18y ago
User Avatar

What else can I help you with?

Continue Learning about Engineering

What is the use of 'pragma' in C language?

The #pragma directive is a compiler specific instruction. There are many things you can tell the compiler. For instance, the #pragma pack n directive tells the compiler to override the /Zpn command line argument and to use a new default structure packing value. To see all of the possible #pragma directives, go to online help, and index by #pragma directives, C/C++. You probably only need to type in #pra and then click on C/C++ to get this far.


What are preprocessor directive?

Preprocessor directives are used to mark code that is specific to a particular compiler and thus to a specific machine architecture. In this way, programmers can write cross-platform code in the same source and let the compiler decide which parts of the source to compile and which to ignore. In reality, the compiler never actually sees the preprocessor directives since the preprocessor creates new files containing only the code that is to be compiled. Hence the preprocessor is often called the precompiler. Normally, the intermediate source files are deleted as they are compiled, however your development environment should contain an option that allows you to view these files so you can see what the compiler actually works with. In C and C++, all preprocessor directives have a leading # symbol, such as #include and #define. #include is by far the most common preprocessor directive. When the precompiler encounters a #include statement, the named header file is essentially copy/pasted in place of the directive. However, all header files should also contain #ifndef header guards to ensure headers are only included once per compilation and these have to be preprocessed as well. Macro definitions are also preprocessed, replacing all instances of the macro symbol with the definition. Macro functions are also inline expanded but since the compiler only sees the expanded code, never the macro itself, the compiler cannot help you debug errant macros. This is why non-trivial macro functions are best avoided.


Why and when do you use the define directive?

The #define preprocessor directive is severely overused in my opinion. Often, you will see programmers write something like this: # define MAX(a, b) (((a) &gt; (b))? (a) : (b)) However doing so is rather dangerous, because the preprocessor replaces things textually. This means that if you pass in a call to a function, it may happen twice, for example: MAX(++i, j) will be expanded to (((++i) &gt; (j))? (++i) : (j)) which is bad. A much safer (and more common) example is that people will use #define to create a constant variable: #define MYCONST 10 This too can cause problems if another file depends on the constant and certain other conditions are met. A safer alternative is to declare a const variable. The one advantage of using #define for literal constants is that the number will not be stored in memory attached to an object like a const variable will.


Use an assembler directive to store the ASCII-character string What time is it in the memory?

To store the ASCII character string &quot;What time is it&quot; in memory using an assembler directive, you can use the .ascii or .asciz directive. For example, in assembly language, you can write: .data timeString: .asciz &quot;What time is it&quot; This directive allocates memory for the string and includes a null terminator, making it suitable for string handling in many programming contexts.


What is a preprocessor in c programming?

Preprocessor instructions are used to modify the compiler's perspective of the source code during the parsing phase, before the compilation phase. The most common preprocessor directives are "include" (place the source code from another file into the current file's parse point), "pragma" (change the compiler's flags), and "define" (define a compile-time constant). Other uses are conditional compilation instructions, such as using one algorithm for a certain platform, and a different one for another platform. Preprocessor directives never appear in the final executable code directly, but instead influence how the rest of the source code will be compiled.

Related Questions

How you can use pragma in c language?

a preprocessor directive that is not an specified ISO standard that controls actions of complier and linker


What is the use of 'pragma' in C language?

The #pragma directive is a compiler specific instruction. There are many things you can tell the compiler. For instance, the #pragma pack n directive tells the compiler to override the /Zpn command line argument and to use a new default structure packing value. To see all of the possible #pragma directives, go to online help, and index by #pragma directives, C/C++. You probably only need to type in #pra and then click on C/C++ to get this far.


How do you set global variables to on?

You can use the preprocessor directive #define, or you can describe a variable in the body of main(). With the preprocessor directive you can make the variable accessible even out of your current project.


Significance of pragma directives in the program?

Pragma directive forces processor to use specific advantages for particular processors such as Hyper Threading, multi cores and so on.


What are preprocessor directive?

Preprocessor directives are used to mark code that is specific to a particular compiler and thus to a specific machine architecture. In this way, programmers can write cross-platform code in the same source and let the compiler decide which parts of the source to compile and which to ignore. In reality, the compiler never actually sees the preprocessor directives since the preprocessor creates new files containing only the code that is to be compiled. Hence the preprocessor is often called the precompiler. Normally, the intermediate source files are deleted as they are compiled, however your development environment should contain an option that allows you to view these files so you can see what the compiler actually works with. In C and C++, all preprocessor directives have a leading # symbol, such as #include and #define. #include is by far the most common preprocessor directive. When the precompiler encounters a #include statement, the named header file is essentially copy/pasted in place of the directive. However, all header files should also contain #ifndef header guards to ensure headers are only included once per compilation and these have to be preprocessed as well. Macro definitions are also preprocessed, replacing all instances of the macro symbol with the definition. Macro functions are also inline expanded but since the compiler only sees the expanded code, never the macro itself, the compiler cannot help you debug errant macros. This is why non-trivial macro functions are best avoided.


How do you use the word directive in s sentence?

The Prime Directive is a basic rule in Star Trek.His directive is that we seek an amiable solution. What is your directive, boss?


Which DoD Directive establishes policy for the use of commercial wireless devices?

DOD 8100.2


What is difference between using declarative method and using directive method?

The simple answer is that directives are symbols that instruct or direct the preprocessor, while declarations are C++ symbols that are processed by the C++ compiler. The preprocessor and the compiler are essentially two completely separate operations. The preprocessor is tasked with modifying your source files in order to produce temporary intermediate source files which the compiler can process more efficiently. These intermediate files contain nothing but C++ code, thus the preprocessor's primary job is to strip out all the comments from your source files. Preprocessor directives are used to instruct the preprocessor in all other modifications, such as where and when to include one file within another and which sections of code are valid for a particular build. This is achieved by #define directives, in conjunction with #ifdef, #else and #endif directives. The #define directive defines a symbol. As the preprocessor encounters these directives, the symbols are placed in a definition table, which includes all the symbols that were initially passed via the command line. Some symbols have no value assigned to them; their presence in the table is sufficient to know they are defined, and the preprocessor can simply act according to whether a symbol is currently defined or not. The #undef directive is the antidote to #define, allowing symbols to be undefined (removed from the table) by the preprocessor. However, #define can also be used to assign a value to a symbol. This value acts a text replacement for the symbol, thus wherever the symbol is encountered within your code (outwith any other directives), the symbol is replaced with the text value associated with that symbol. These are known as macros. #define can also be used to declare macro functions, where the text replacement includes one or more arguments within parenthesis, followed by C++ code that processes those arguments. Thus all occurrences of the symbol in your code must include an argument list with the same number of arguments as the macro directive. The preprocessor then inline expands the macro function, replacing its arguments with the formal arguments provided by your code. The problem with #define in general is that it is not a C++ statement, it is a macro, and macros are not subject to the strong-typing that is fundamental to C++. So while you can use #define to declare literal constants, those constants are untyped. Moreover, since the compiler never sees the macro definition (it is stripped from the intermediate file), any errors that occur as a result of a macro expansion cannot be sourced back to the macro, which makes debugging difficult at best. In the case of macro functions, the debugger cannot help you at all, you're completely on your own. Thus when you have the option to use directives or declarations, always go with a declaration. C++ code is type safe, can be easily debugged, is easier to maintain, and usually results in much smaller compiled code. Only use the preprocessor to generate code that would be difficult or impossible to generate with the compiler alone. In other words, use directives specifically to direct the preprocessor. Never rely on them to generate C++ code unless you have no other option, or it would greatly simplify a far more complex C++ implementation.


What does php mean in Chinese?

PHP is "Hypertext Preprocessor", use google translator to make it Chinese :D


What should be the startup type of service that should not load at startup but might be used later after startup?

Manual Startup. Use services.msc in command prompt to set the startup.


How to overcome structure padding?

I think we can use #pragma pack(1) By this the structure will he paked in 1 byte order so there will be no waste of memory .


What utility does vista use to manage startup programs?

Msconfig Use Software Explorer to view and stop startup programs in Vista.