Hi all,
i came across this problem when i was trying to code sorting of strings posted in happycodingc.blogspot.com...
Scenario:
In the first occurence of scanf()when we enter data to it we tap ENTER key ,and this remains in the STDIN,when we encounter the progressive input functions like Scanf ,fgetc and fgets, then the input to it will be a NEWLINE character as the value in the STDIN is still unread and when the second input function tries to read from the STDIN and it will read '\n' due to enter key and this is not expected...sp we can avoid this by using getchar()in and fflush(stdin)in c++.
check the example
also try uncommenting the getchar();
int main()
{
int iTest;
char cTest;
scanf("%d",&iTest);
// getchar();
scanf("%c",&cTest);
}
Thursday, April 22, 2010
Tuesday, April 20, 2010
Naming Conventions To Be Used While Coding(Exclusively for Win32 programming)
The following table lists common prefixes.
These are often combined, as in the following.
Other conventions are listed in the following table.
| Prefix | Description |
|---|---|
| a | Array |
| b | BOOL (int) |
| c | Char |
| cb | Count of bytes |
| cr | Color reference value |
| cx | Count of x (short) |
| dw | DWORD (unsigned long) |
| f | Flags (usually multiple bit values) |
| fn | Function |
| g_ | Global |
| h | Handle |
| i | Integer |
| l | Long |
| lp | Long pointer |
| m_ | Data member of a class |
| n | Short int |
| p | Pointer |
| s | String |
| sz | Zero terminated String |
| tm | Text metric |
| u | Unsigned int |
| ul | Unsigned long (ULONG) |
| w | WORD (unsigned short) |
| x,y | x , y coordinates (short) |
These are often combined, as in the following.
| Prefix combination | Description |
|---|---|
| pszMyString | A pointer to a string. |
| m_pszMyString | A pointer to a string that is a data member of a class. |
Other conventions are listed in the following table.
| Convention | Description |
|---|---|
| CMyClass | Prefix 'C' for C++ class names. |
| COMyObjectClass | Prefix 'CO' for COM object class names. |
| CFMyClassFactory | Prefix 'CF' for COM class factory names. |
| IMyInterface | Prefix 'I' for COM interface class names. |
| CImpIMyInterface | Prefix 'CImpI' for COM interface implementation classes. |
Subscribe to:
Comments (Atom)