How can i write the code to identify the smallest integer i entered and how many times it appeared in the list i key in?
Can somebody please help?
#include<stdio.h>
#define constant-999
int main()
{
int num, count;
printf("Enter a list of integers (-999 to stop) : ");
while(scanf("%d", &num) != -999)
...
C/C++ would be good option to write some of the performance critical aspects of a Ruby Application. I know this is possible.
I would like to know how to add C/C++ code into Ruby code; any other language for that matter.
Are there any practical applications of this which you noticed in open source projects or else?
...
I am taking a course on computational geometry in the fall, where we will be implementing some algorithms in C or C++ and benchmarking them. Most of the students generate a few datasets and measure their programs with the time command, but I would like to be a bit more thorough.
I am thinking about writing a program to automatically gen...
[Edit: It seems this is an issue on gcc versions prior to 4.4, I got confused because of a gcc bugzilla entry reporting it for 4.5 (latest). Sorry, I should've tested with more recent versions. Still, the problem is somewhat valid as most people don't run gcc 4.4+.]
Is it possible to tell the compiler the variable used in a switch fits ...
The main() function in an avr-gcc program saves the register state on the stack, but when the runtime calls it I understand on a microcontroller there isn't anything to return to. Is this a waste of RAM? How can this state saving be prevented?
...
The evaluation order does matter a lot, so, is this something called non-referential-transparency?
int i = 1;
int counter(){
i = i + 1;
return i;
}
int foo(int i, int j){
return i*2 + 3*j;
}
int main(){
printf("%d", foo(counter(), counter()));
}
...
I made a program which removes spaces and makes a string upper case by preprocessor directives .its not changing to uppercase
#include <stdio.h>
#include <conio.h>
# define TOUPPER(x) (x-32)
void main(void)
{
int i,j;
char str[100],*p;
clrscr();
printf("Enter the string:\n");
gets(str);
for(i=0; ;i++)
{
...
Text file (or CSV) is:
Data:,,,,,\n
(but with 100 ","s)
In C or C++ I would like to open the file and then fill in values between the ",".
i.e.- Data:,1,2,3,4,\n
I'm guessing that I need some sort of search to find the next comma, insert data, find the next comma insert, etc.
I was looking at memchr() for a buffer and...
I have a legacy code implemented in C (not C++). I would like to be able to call a few methods in this C code from my C# code (on Windows). What would be the best approach to interface between the two language? Please note that the method in C is not stateless. We need to call two methods:
initialization() => this will initialize the d...
Hi,
So on Project Euler the Problem 4 states the following:
A palindromic number reads the same
both ways. The largest palindrome made
from the product of two 2-digit
numbers is 9009 = 91 99.
Find the largest palindrome made from
the product of two 3-digit numbers.
I have tried the following:
#include <stdio.h>
...
Hello,
I would like to use the GetVolumeInformation call to retrieve the name of a removable device. I can retrieve the name just fine and store into a TCHAR array variable szVolNameBuff. Here is my code for that:
// Get Volume Information to check for NTFS or FAT
TCHAR szFileSys[256];
TCHAR szVolNameBuff[256];
DWORD dwSerial ...
I'm wondering if simply compiling my msvc project with sse/sse2 will have any effect. I do for example vector normalization and dot product but I do these wth math, not any specific function. Is there like sse_dot() and sse_normalize() that I should be using to actualyy take advantage, or will the compiler know?
Thanks
...
Hi,
So as we all probably know, the atoi converts a char to a number. But, what do you do if you only want one of the array elements instead of the whole array?
Please look at the following:
for (h = 0; h < 5; h++)
{
num[h] = atoi(temp[h]);
}
Assume that num is an array of type int and that temp is and array of type char. This g...
I tried to use several implementations, but all of them had bugs.
Search at SO gave me http://www-igm.univ-mlv.fr/~lecroq/string/node14.html - looks nice, but this implementation gave me wrong results - sometimes it doesn't found a string.
I spent couple hours to find the bug.
Following line looks fine:
j += MAX(bmGs[i], bmBc[y[i + j]]...
I want to write a wrap for a DLL file, in this case for python. The problem is that the argument types are not the C standard ones. They have been typedef'end to something else.
I have the header files for the DLL files... so I can manually track the original standard C type the argument type was typedef'ined to. But wanted a more syste...
I am currently writing a programming language in C/C++ as an exercise (but mostly for fun). At the moment it compiles into a list of commands that are then executed (kind of like a low-level API). Its working fantastically, however, I think it would be more exciting if instead of having a interpreter executable, having the language act...
When we build a programe,some symbols are to be resolved at link time(like those in a .lib),
but some can be resolved at run time(those in a .dll),
my doubt is that how does the compiler know about this, or how do we notify the compiler about this?
...
How do I print #include<conio.h> in C
#include<stdio.h>
#include<conio.h>
void main()
{
printf("#include<conio.h>");
}
How to get the output as
#include<conio.h>
you have to put getch(); and press Ctrl+f9 instead of alt+f5
...
hi,
char **r;
r = (char **)malloc(10);
the above allocation is enough?dont i need allocate for char *r through for loop?any can explain which one is right?
...
I have two arrays, say A and B with |A|=8 and |B|=4. I want to calculate the set difference A-B. How do I proceed? Please note that there are no repeated elements in either of the sets.
Edit: Thank you so much everybody for a myriad of elegant solutions. Since I am in prototyping stage of my project, for now I implemented the simplest s...