how to read string entered by user in c
hello i want to read the name entered by my user using c programmes for this i wrote: chat name[20]; printf("Enter name:"); gets(name); but using gets is not good so suggest me a better way. ...
hello i want to read the name entered by my user using c programmes for this i wrote: chat name[20]; printf("Enter name:"); gets(name); but using gets is not good so suggest me a better way. ...
A .NET Micro Framework device (ChipworkX in this case) sends a byte through the SPI interface to a Pic18f. Having PIE1bits.SSPIE enabled the following code is executed on interrrupt: void high_isr (void) { PIE1bits.SSPIE = 0; PIR1bits.SSPIF = 0;// Clear interrupt flag LATDbits.LATD5=1;//enables led for high interr...
I have a quick question, suppose I have the following code and it's repeated in a simliar way 10 times for example. if blah then number = number + 2^n end if Would it be faster to evaluate: number = number + blah*2^n? Which also brings the question, can you multiply a boolean value times a integer (Although I am not sure the ty...
In many programs a #define serves the same purpose as a constant. For example. #define FIELD_WIDTH 10 const int fieldWidth = 10; I commonly see the first form preferred over the other, relying on the pre-processor to handle what is basically an application decision. Is there a reason for this tradition? ...
const struct sockaddr FAR* name, ...
Hi friends, I got the following simple C++ code: #include <stdio.h> int main(void) { ::printf("\nHello,debugger!\n"); } And from WinDbg, I got the following disassembly code: SimpleDemo!main: 01111380 55 push ebp 01111381 8bec mov ebp,esp 01111383 81ecc0000000 sub esp,0C0h 01111389 53 ...
I have the following C application: #include <stdio.h> void smash() { int i; char buffer[16]; for(i = 0; i < 17; i++) // <-- exceeds the limit of the buffer { buffer[i] = i; } } int main() { printf("Starting\n"); smash(); return 0; } I cross-compiled using the following version of gcc: armv5...
Hi I compiled the delphichromiumembedded using Borland Studio 2006 (c++) , and tried to use the CefRegisterExtension that in the ceflib.dll , I translate the Delphi code of the Execute function to C++ but seems that this doesn't work , I did it using the GetInterface of DelphiInterface Class. here is a sample code , if somebody know ...
Let arr be an array of dimension 16 x 20 Here is the valgrind output for the code snippet mentioned. The output is from cachegrind. for (i = 0; i < 20; i++) arr[0][i] = 0; Ir I1mr I2mr Dr D1mr D2mr Dw D1mw D2mw 64 0 0 41 0 0 1 0 0 60 0 0 20 0...
H! I have source in C, which is use the socket(AF_INET, SOCK_STREAM, 0); C method. I use the NDK and make the jni. Everything is fine, but the application don't work correctly; The original C method return 5 in the console. In Android that value is -1. I try to add the C source file the #include < socket.h>, but this is not the solutio...
Possible Duplicate: how to find the location of the executable in C I would like an executable to be able to discover its own path; I have a feeling that the answer is "you can't do this", but I would like this to be confirmed! I don't think I can use getcwd(), because I might not be executing it from the same directory. I d...
help needed printing array of pointers to structs where am i going wrong ? please help include <stdio.h> include <stdlib.h> define HOW_MANY 7 char *names[HOW_MANY]= {"Simon", "Suzie", "Alfred", "Chip", "John", "Tim", "Harriet"}; int ages[HOW_MANY]= {22, 24, 106, 6, 18, 32, 24}; struct person { char *name; int age; }; ...
scanf("%s",str) won't do it. It will stop reading at the first space. gets(str) doesn't work either when the string is large. Any ideas? ...
From the number of questions posted here, it's clear that people have some pretty fundemental issues when getting their heads around pointers and pointer arithmetic. I'm curious to know why. They've never really caused me major problems (although I first learned about them back in the Neolithic). In order to write better answers to thes...
Is using C in C++ bad? Many people have told me that using C in C++ is bad because it's not as safe, and it requires more memory management. I keep telling them that as long as you know what your doing, and you delete your new's and free your malloc's then C isn't a problem. I'm currently on a forum where an argument over std::string v...
Hi, debugging in MonoDevelop does not work for me. First of all, I have installed MonoDevelop, GNU Debugger plugin and ctags through Ubuntu software center and I'm using Ubuntu 10.10. When I press "Debug" it goes into debug mode but very quickly returns to "normal mode". My simple application contains some scanf so it should wait for i...
Suppose we have an array say: int arr[1000]; and I have a function that works on that array say: void Func(void); Why would there ever be a need to pass by reference (by changing the void), when I can have arr[1000] as an external variable outside main()? What is the difference?Is there any difference? Why do people prefer passin...
I have a function which determines if an array needs to be smoothed. I have multiple arrays that this operation needs to be preformed on. I'd like to use the sections construct in OpenMP to do this. Unfortunately, I'm running into segmentation faults as soon as the code grows in an appreciable size. This may be a memory limitation is...
Background: We're modeling the firmware for a new embedded system. Currently the firmware is being modeled in UML, but the code generation capabilities of the UML modeling tool will not be used. Target language will be C (C99, to be specific). Low power (i.e. performance, quick execution) and correctness are important, but correctnes...
Hi! I've used the following C macro, But in C++ it can't automatically cast void* to type*. #define MALLOC_SAFE(var, size) { \ var = malloc(size); \ if (!var) goto error; \ } I know, I can do something like this: #define MALLOC_SAFE_CPP(var, type, size) { \ var = (type)malloc(size); \ if (!var) goto error; \ } But ...