#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
char arr[200],res[200];
char table[150][200];
string multiply(char n[],int m)
{
int N=strlen(n),M,temp=0,x=0;
for(int i=0;i<N;i++)
arr[i]=n[N-1-i];
for(int i=0;i<N;i++)
{
x=m*(arr[i]-'0')+temp;
x=m*(arr[i]...
How would I go about reading a string from stdin and formatting as such to stdout?
For example:
If I receive someone's name:
John Doe 03 17
I want to create user name for him as such:
jd0317
Although it can change to for someone with a middle name:
Jane B. Doe 05 18
Then it would be:
jbd0518
I assume you would read the line and then...
Hash Tables are said to be the fastest/best way of Storing/Retrieving data.
My understanding of a hash table, hashing is as follows (Please correct me if I am wrong or Please add If there is anything more):
A Hash Table is nothing but an array (single or multi-dimensional) to store values.
Hashing is the process to find the index/loca...
Here's a problem thats got me stumped (solution wise):
Given a str S, apply character mappings Cm = {a=(m,o,p),d=(q,u),...} and print out all possible combinations using C or C++.
The string can be any length, and the number of character mappings varies, and there won't be any mappings that map to another map (thus avoiding circular d...
I have a C/C++ program that's a plugin to Firefox. Because it's a plugin, it has non-main entry points. Those entrypoints need to be compiled in C because otherwise they get name mangled.However, other functions are over-loaded, so they need to be C++. The solution is extern "C". That much I've already figured out.
However, if I extern ...
Hi Folks,
Just a quick question for folks who know a bit of c. Whats the significane fo a * at the start of an expression.
as in...
If (this == thisThingOverHere)
ThisThing = *((WORD *) &Array[withThisPosition]);
You can assume WORD is a 16-bit unsigned and Array is an 8 bit byte array.
Its surprisingly difficult to try and find out ...
Is there an API in C that I can use to check whether file indexing is on or off?
Code is appreciated.
...
Is there a way to specify how many characters of a string to print out (similar to decimal places in ints)
printf ("Here are the first 8 chars: %s\n", "A string that is more than 8 chars");
Would like it to print: "Here are the first 8 chars:A string"
...
Hello,
While programming in C and GTK+, Why is it "better" to use g_strdup_printf, g_free, g_strcmp0 etc... and fellow glib functions?
Merci!
...
We have a library with very complex logic implemented in C. It has a command line interface with not too complex string-based arguments. In order to access this, we would like to wrap the library so that it can be accessed with simple XML RPC or even straightforward HTTP POST calls.
Having some experience with Java, my first idea would ...
Hey,
I want to make a DNS query to my own DNS server instead the default one.
Which api can I use to do that ?
I know getaddrinfo (which ping.exe using), but how can i make this function query my dns server, instead the default one ?
Thanks!
...
I have a struct sockaddr and need to make a struct addrinfo (specifically that, because that's what some other API wants). The IP address may be IPv4 or IPv6. What's the best way to handle that?
...
Suppose I define a struct in "struct.h" like so
struct box {
int value;
}
and I use that struct in another file say "math.c"
#include "struct.h"
struct box *sum(struct box *a1, struct box *a2) {
struct box *a3 = malloc(sizeof (struct box));
a3->value = a1->value + a2->value;
return a3;
}
would "math.h" need to inc...
Hello,
Using visual studio 2008, I have an .H and a .LIB file of a library.
I wrote a program and refrenced the LIB via the project properties.
It compiles fine, but when it runs, it asks for the DLL to be installed.
If the DLL is in the same dir as the EXE it works ... but, if I have the LIB, doesn't it already mean the functions are s...
I want to have code that looks something like this...
static linked_list* globalListHoldingAllSortsOfGoodies = initialize_linked_list();
/* [In a different file...] */
static int placeholder = add_to_global_list(goodies);
But non-constant initialization is impossible in C.
Is there some way to get the same affect without breaking C8...
I am writing C for an MPC 555 board and need to figure out how to allocate dynamic memory without using malloc.
...
I found this in initramfs.c, I haven't seen this syntax before, could some one explain what it is doing?
static __initdata int (*actions[])(void) = {
[Start] = do_start,
[Collect] = do_collect,
[GotHeader] = do_header,
[SkipIt] = do_skip,
[GotName] = do_name,
[CopyFile] = do_copy,
[GotSymlink] = do_symlink,
[Reset] ...
I have a structure containing character arrays with no any other member functions. I am doing assignment operation between two instances of these structures. If I'm not mistaken, it is doing shallow copy. Is shallow copy safe in this case?
I've tried this in C++ and it worked but I would just like to confirm if this behavior is safe.
...
While I was reading the reference about fopen function, I found out that FOPEN_MAX is a value that the "minimum number of streams that the implementation guarantees can be open simultaneously".
Why it is the minimum number of streams? Doesn't it have to be "the maximum number of streams...." ?
...
I'm want to learn C programming with K&R using XCode, but I can't even get the Hello World to work right - it's giving me errors it shouldn't, I guess because it's being very technical. Can I get XCode to relax on requirements? Would greatly appreciate some advice! Thanks.
...