|
can anyone kmow how to program my problem about looping and factorial in c programming? please....ill w8 for your reply...
|
|
|
|
|
What is the problem, then?
---
b { font-weight: normal; }
|
|
|
|
|
Non-recursive version (not tested):
-----------------------------------
<br />
int Calc(int i) {<br />
<br />
int fact = 1;<br />
for (int j = i; j > 1; j--)<br />
fact *= j;<br />
<br />
return fact;<br />
}<br />
Recursive version (from MSDN):
------------------------------
<br />
int Calc(int i) { <br />
return((i <= 1) ? 1 : (i * Calc(i-1))); <br />
}<br />
|
|
|
|
|
|
I’ve mad an application (or apart of an app) in C++ that I’d like to use in .NET C# Windows Application.
The thing I like to accomplish is to build some kind of component of my existing C++ app and expose some functions that I later can call from the C# app.
The application I like to encapsulate can be seen ass a window (MFC CWnd in my case).
My fist question is if this is possible? If, then my second Q is How..?
I’ve made som COM and ActiveX programming but I don't (if it's possible) want to solve my problem that way.
I’m not expecting a total solution of my problem but Ideas where to start would be great.
Articles about this would be great. (Have not found any of them myself…)
_____________________________
...and justice for all
APe
|
|
|
|
|
Hello gurus,
As the subject of this topic says, I wish to know how to concatenate 2 nibbles to give 1 byte in C#?
Thanks for the help.
Best regards.
There is no spoon.
|
|
|
|
|
Multiply the most significant nibble by 16 and add them together.
---
b { font-weight: normal; }
|
|
|
|
|
hi guffa,
a code snippet maybe? thanks
There is no spoon.
|
|
|
|
|
|
ah, just what I needed
Thanks
There is no spoon.
|
|
|
|
|
Use the following code :
byte nib1,nib2,finalByte;
finalByte = (nib1 << 4) | (nib2 & 0x0f);
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
|
|
|
|
|
Thanks!
There is no spoon.
|
|
|
|
|
When I dispose Control calling Control.Dispose() method, deactivate window and then re-activate window, I get ObjectDisposedException .
Does anybody know how to avoid Windows.Forms creating handle of a disposed control?
|
|
|
|
|
If I'm reading this right. You have a form with a control, and then in your code you dispose of the control? So when you try to activate the window it throws the exception about the disposed object? That's because your form thinks it still exists when you go to re-activate the window. Before you dispose the object, you should remove it from the form with form.controls.remove(yourControl). Then you can dispose of the object all you want.
|
|
|
|
|
When I use Controls.Remove(Control), the form start to working weird. It seems to be inactive (light blue) and blinking when clicked, but still keeping inactive.
I also tried to use SuspendLayout() and ResumeLayout() methods. Nothing changed.
And when all things worked (I had to remove more controls), Windows.Forms already tried to access correctly REMOVED and DISPOSED object calling its CreateHandle() method.
The last thing I've done was to change design of my app. I have no more time to solve these bugs, maybe later.
Thanks for answer!
|
|
|
|
|
Hi Every Body
I want to use Visual Studio.Net Code Editor in my Winform Application to make a script editor. Is it possible to use Visual Studio.Net Code editor.
I need text highlighting and auto expression completion in my script editor.
Thank you for your help.
|
|
|
|
|
|
I would like to develop a Clock Application. It should not depend upon the System clock. That is when the System time changes the clock tmie should not change. The clock should run independantly. Please give me the code or Logic. Thanking You
Suseel Kumar P
-- modified at 3:44 Saturday 3rd September, 2005
|
|
|
|
|
You can use System time as well. Only difference between system and your time could be a shift.
Look at the DateTime structure at MSDN or somewhere else. Your can set your clock to any time you want, then compute a shift between your time and system time. Everywhen you want to update your time, just compute: system time + difference. It's not extremely accurate (in the mean of milliseconds), but it may be enough for your application.
|
|
|
|
|
having the typeof(something), can I create a new (default constructed) instance from that?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Yes, see the Activator.CreateInstance method.
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
|
|
|
|
|
Yes, use the Activator.CreateInstance method.
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
|
|
|
|
|
|
00001 <br />
00038 #include <stdio.h><br />
00039 #include <sys/types.h><br />
00040
00041
00042 #include "wildmat.h"<br />
00043 <br />
00044 <br />
00045 #define TRUE 1<br />
00046 #define FALSE 0<br />
00047 #define ABORT -1<br />
00048 <br />
00049 <br />
00050 <br />
00051 #define NEGATE_CLASS '^'<br />
00052 <br />
00053 #define OPTIMIZE_JUST_STAR<br />
00054 <br />
00055 #undef MATCH_TAR_PATTERN<br />
00056 <br />
00057 <br />
00058 <br />
00061 static int DoMatch(text, p)<br />
00062 register char *text;<br />
00063 register char *p;<br />
00064 {<br />
00065 register int last;<br />
00066 register int matched;<br />
00067 register int reverse;<br />
00068 <br />
00069 for (; *p; text++, p++) {<br />
00070 if (*text == '\0' && *p != '*')<br />
00071 return ABORT;<br />
00072 switch (*p) {<br />
00073 case '\\':<br />
00074 <br />
00075 p++;<br />
00076 <br />
00077 default:<br />
00078 if (*text != *p)<br />
00079 return FALSE;<br />
00080 continue;<br />
00081 case '?':<br />
00082 <br />
00083 continue;<br />
00084 case '*':<br />
00085 while (*++p == '*')<br />
00086 <br />
00087 continue;<br />
00088 if (*p == '\0')<br />
00089 <br />
00090 return TRUE;<br />
00091 while (*text)<br />
00092 if ((matched =<br />
00093 DoMatch(text++, p)) != FALSE)<br />
00094 return matched;<br />
00095 return ABORT;<br />
00096 case '[':<br />
00097 reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE;<br />
00098 if (reverse)<br />
00099 <br />
00100 p++;<br />
00101 matched = FALSE;<br />
00102 if (p[1] == ']' || p[1] == '-')<br />
00103 if (*++p == *text)<br />
00104 matched = TRUE;<br />
00105 for (last = *p; *++p && *p != ']'; last = *p)<br />
00106 <br />
00107 if (*p == '-' && p[1] != ']'<br />
00108 ? *text <= *++p<br />
00109 && *text >= last : *text == *p)<br />
00110 matched = TRUE;<br />
00111 if (matched == reverse)<br />
00112 return FALSE;<br />
00113 continue;<br />
00114 }<br />
00115 }<br />
00116 <br />
00117 #ifdef MATCH_TAR_PATTERN<br />
00118 if (*text == '/')<br />
00119 return TRUE;<br />
00120 #endif /* MATCH_TAR_ATTERN */<br />
00121 return *text == '\0';<br />
00122 }<br />
00123 <br />
00124 <br />
00125 <br />
00128 int wildmat(const char *text, const char *p)<br />
00129 {<br />
00130 #ifdef OPTIMIZE_JUST_STAR<br />
00131 if (p[0] == '*' && p[1] == '\0')<br />
00132 return TRUE;<br />
00133 #endif /* OPTIMIZE_JUST_STAR */<br />
00134 return DoMatch(text, p) == TRUE;<br />
00135 }<br />
00136 <br />
00137 <br />
00138 <br />
00139 #if defined(TEST)<br />
00140 <br />
00141 <br />
00142 extern char *gets();<br />
00143 <br />
00144 <br />
00145 int main()<br />
00146 {<br />
00147 char p[80];<br />
00148 char text[80];<br />
00149 <br />
00150 printf("Wildmat tester. Enter pattern, then strings to test.\n");<br />
00151 printf<br />
00152 ("A blank line gets prompts for a new pattern; a blank pattern\n");<br />
00153 printf("exits the program.\n");<br />
00154 <br />
00155 for (;;) {<br />
00156 printf("\nEnter pattern: ");<br />
00157 (void) fflush(stdout);<br />
00158 if (gets(p) == NULL || p[0] == '\0')<br />
00159 break;<br />
00160 for (;;) {<br />
00161 printf("Enter text: ");<br />
00162 (void) fflush(stdout);<br />
00163 if (gets(text) == NULL)<br />
00164 exit(0);<br />
00165 if (text[0] == '\0')<br />
00166 <br />
00167 break;<br />
00168 printf(" %s\n",<br />
00169 wildmat(text, p) ? "YES" : "NO");<br />
00170 }<br />
00171 }<br />
00172 <br />
00173 exit(0);<br />
00174 <br />
00175 }<br />
00176 #endif /* defined(TEST) */<br />
<br />
|
|
|
|
|