I am reaing from a file, and when i read, it takes it line by line, and prints it
what i want exactly is i want an array of char holding all the chars in the file and print it once,
this is the code i have
if(strcmp(str[0],"@")==0)
{
FILE *filecomand;
//char fname[40];
char line[100];
...
how do you divide two integers and get a decimal answer? in xcode..
the only thing i could was find http://www.gnu.org/s/libc/manual/html_node/Integer-Division.html
this method will not allow me to have a decimal answer...
...
Hello folks,
This one is probably very simple, but I can't seem to get it working.
I have this very simple snippet of code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char buf[100];
char *p = buf;
strcpy(p, "Test string");
printf("%s\n", *p);
}
Which causes a segmentation fault when I run it. GDB outputs:
...
line by line, there are inputs.
first line will be stored in as[0]
second one is as[1]
...
how input line ends is not known (maybe it end with EOF or new line character)
how should I take input
...
void get_formula_and_intervals()
{ int i=0;
while(1)
{ if(scanf("%c",&(infix_formula[i]))!=1)
{ infix_formula[i]='\0';
break;
}
if(infix_formula[i]==' ')
continue;
...
Hi
I have a code snapshot
#if XXX1
typedef XCC {
....
}XCC;
....
#endif
eclipse doesn't index this structure? How can I make eclipse index this?
...
for example suppose that some k which is arbitrary number=2 k=2 then there is code in c
int wordcomp(char *p, char *q) {
int n = k;
for ( ; *p == *q ; p++, q++) {
if ( *p==0 && --n == 0 )
return 0;
}
return *p - *q;
}
please explain me what does this code do? also what means *p-*q?and also how im...
void my_cool_function()
{
obj_scene_data scene;
obj_scene_data *scene_ptr = &scene;
parse_obj_scene(scene_ptr, "test.txt");
}
Why would I ever create a pointer to a local variable as above if I can just do
void my_cool_function()
{
obj_scene_data scene;
parse_obj_scene(&scene, "test.txt");
}
Just in case it's ...
From man gets:
Never use gets(). Because it is
impossible to tell without knowing the
data in advance how many
characters gets() will read, and
because gets() will continue to store
characters past the end of the buffer,
it is extremely dangerous to use.
It has been used to break computer
security. Use fg...
So in my game I need to simulate the physics in a hardware independent manner.
I'm going to use a fixed time-step simulation, but I need to be able to calculate how much time is passing between calls.
I tried this and got nowhere:
#include <time.h>
double time_elapsed;
clock_t last_clocks = clock();
while (true) {
time_elapsed = ( (...
Hi!
I want the following code to print 11, but prints 12, except in the last case, where it prints 10.
x=5; x1=x+(x=6); printf("%d\n",x1);
x=5; x1=(x=x)+(x=6); printf("%d\n",x1);
x=5; x1=(x+0)+(x=6); printf("%d\n",x1);
x=5; x1=(x=5)+(x=6); printf("%d\n",x1);
x=5; x1=(x=6)+x; printf("%d\n",x1);
x=5; x1=(x=6)+(x=x); printf("%d...
i have an array of type char
char *arg[100]
this array its reading the data from somewhere, when that when i print arg[0], it prints the value "help", and when i print the arg[1], it prints the value "exit".. as an example
what i want exactly is to change the arg[0] from "help" to anything else, like "man"
how i can do that???
than...
Possible Duplicate:
What does unsigned temp:3 means
I just found this code in a book (was used in an example)
typedef struct {
unsigned int A:1;
unsigned int B:1;
unsigned int C:1;
} Stage;
What is the meaning of this structure definition? (the A:1;)
...
I'm trying to write depth first search in C. In the search instead of maintaing a set of all the reachable nodes I instead have to mark the isVisited field in Vertex as a 1 for visited. Here's my data structs and my algo attempt.
struct Vertex {
char label;
int isVisited;
int numNeighbors;
struct Vertex** neighbors;
};
...
I have a C# prototype that is heavily data parallel, and I've had extremely successful order of magnitude speed ups using the Parallel.For construct in .NETv4. Now I need to write the program in native code, and I'm wondering what my options are. I would prefer something somewhat portable across various operating systems and compilers, b...
Im trying to write a few simple macros to simplify the task of setting and clearing bits which should be a simple task however I cant seem to get them to work correctly.
#define SET_BIT(p,n) ((p) |= (1 << (n)))
#define CLR_BIT(p,n) ((p) &= (~(1) << (n)))
...
Hi folks,
I am experimenting with variable argument lists and seeing some strange results...
The piece of code I am testing is:
#include <stdio.h>
#include <stdarg.h>
void foo(int param1, int param2, ...)
{
int param3 = 0;
va_list ap;
va_start(ap, param2);
param3 = va_arg(ap, int);
va_end(ap);
printf("param3...
Which configuration management tool is the best for FPGA designs, specifically Xilinx FPGA's programmed with VHDL and C for the embedded (microblaze) software?
...
I'm in the middle of porting David Blei's original C implementation of Latent Dirichlet Allocation to Haskell, and I'm trying to decide whether to leave some of the low-level stuff in C. The following function is one example—it's an approximation of the second derivative of lgamma:
double trigamma(double x)
{
double p;
int i;
...
Hello,
gcc 4.4.4 c89
I will be adding to this list. So I am looking to NULL terminate it. However, I am getting a warning: "Initialization makes integer from pointer without a cast"
Why does the it mention integer when I haven't used in that structure?
I was thinking in this case arrays and pointers where the same?
struct company_p...