I need to store the following strings in 3 char * variables in C:
[foo]
[foo]:[bar]
[foo]:[bar]:[tat]
Each individual string such as "foo" is received at one point of time via a char* pointer, the corresponding output string is produced immediately before receiving the second string, and the total number of individual strings is known...
#include "stdio.h"
#include "conio.h"
void swap(int *x,int *y);
void main()
{
int a=10,b=20;
swap(a,b);
printf("value of a=%d and b=%d");
getch();
}
void swap(int *x,int *y)
{
if(x!=y)
{
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
// I'm getting .. cann't convert int to int * ...
can anybody tell me why ...
I wrote a code to read files
What is wrong in the following code I am always getting last filename if I print any arrayItem
#include <stdio.h>
#include <string.h>
char **get_files()
{
FILE *fp;
int status;
char file[1000];
char **files = NULL;
int i = 0;
/* Open the command for reading. */
fp = popen("ls"...
Is the Linker part of the Operating System or the Compiler/IDE?
...
I had a similar question here about allocating and initializing one pointer to struct in a subfunction. Unfortunately I can't extend the good solution I got there to initialize an array of structs.
The first element is OK but the second (and all following) elements are zero/NULL.
Here is a commented example. Maybe someone can help me......
This was prompted by some experimenting with C/C++; neither the statement
printf("\a");
nor the statement
cout << "\a";
produce an audible bell sound. How is the \a supposed to function . . .
...
I want to write a C program that will sample something every second (an extension to screen). I can't do it in a loop since screen waits for the program to terminate every time, and I have to access the previous sample in every execution. Is saving the value in a file really my best bet?
...
I'm making a 3D FPS with OpenGL and here is the basics of how it works. The game is a 3D array of cubes. I know the location of the player's current cube, aswell as the camera x,y,z and I know the x, y, z rotation of the camera too. Right now I just make a square around the player and render this and then add distant fog. The problem tho...
I know that OS kernels are made up of drivers, but how does the driver become a part of the os?, does the kernel decompile itself, and then add the driver and recompile itself?, or are the drivers plug-ins for the kernel?, someone told me that for most operating systems, the drivers actually become a part of the kernel, but whenever I co...
So, I've got the following code (C):
char c = getc(in);
if (c == '(')
...
if (c == '%')
...
if (isdigit(c))
{
int n;
ungetc(c, in);
scanf("%i", &n);
...
}
Everything is all fine and dandy when I'm reading in input from stdin but, when reading in input from from a file, the call to scanf does not terminate.
I added s...
I am trying to understand the assembly level code for a simple C program by inspecting it with gdb's disassembler.
Following is the C code:
#include <stdio.h>
void function(int a, int b, int c) {
char buffer1[5];
char buffer2[10];
}
void main() {
function(1,2,3);
}
Following is the disassembly code for both main and functio...
Hi,
I learned that memset(ptr, 0, nbytes) is really fast, but is there a faster way (at least on x86)?
I assume that memset uses mov, however when zeroing memory most compilers use xor as it's faster, correct?
Also I asked a person who knew of assembler more than me to look at the stdlib, and he told me that on x86 memset is not taki...
Hello,
Does anyone know how I can add a progress bar to a listview cell using "pure" api. The only examples I've found are either in c# or outdated mfc
...
As far as I can tell, asprintf calls malloc. If I replace malloc with the Boehm GC, a call to asprintf still calls the traditional malloc - at least that's what valgrind is telling me:
Here's the malloc macro:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <gc.h>
#define malloc(n) GC_MALLO...
More than likely a rookie question, but I'm looking for a printf-esque function for use in send over TCP sockets. This is for a simple chat server, specifically a modified version of the one in Beej's socket guide. I'm prepared to write my own, but before I do I want to make sure I'm not reinventing the wheel.
I'm looking for something ...
Can someone explain why I can do:
int x[4] = { 0, 1, 2, 3 };
int *p = x;
But cannot do:
int x[2][2] = { 0, 1, 2, 3 };
int **p = x;
Is there a way to be able to assign to **p the x[][]?
TIA
...
Whilst reading through K&R, I came across the integer to string function. I gave it a quick read, and decided to implement it myself, but instead of printing, it updates a character array.
Here is what I have
void inttostr(int number, char str[]) {
static int i;
if (number / 10) {
inttostr(number / 10, str);
} ...
hi.
i have this code (im working with big files support in ansi c)
unsigned long int tmp,final
final=1231123123123213
tmp=final;
printf("%llu %llu \n",final,tmp);
printf("%llu \n ",tmp);
it prints
1231123123123213 0
1231123123123213
i dont get it
...
Why do I get the wrong values when I print a int using printf("%f, myNumber) ?
I don't understand why it prints fine with %d, but not with %f. Shouldn't it just add extra zeros?
int a = 1;
int b = 10;
int c = 100;
int d = 1000;
int e = 10000;
printf("%d %d %d %d %d\n", a, b, c, d, e); //prints fine
printf("%f %f %f %f %f\n", a, b, c...
I am developing a project in C++. I realised that my program is not OO.
I have a main.cpp, and several headers for different purposes. Each header is basically a collection of related functions with some global variables to retain data. I also have a windowing.h for managing windows. This contains the winMain() and winProc(). It calls t...