C - Check if a value is a number?
How can I check if an integer initialized from function scanf is a number? ...in the simpler way possible thanks :) ...
How can I check if an integer initialized from function scanf is a number? ...in the simpler way possible thanks :) ...
I'm facing a very weird problem. This is map.h: #define MAP_WIDTH 256 #define MAP_HEIGHT 256 typedef struct { char exit_n; char exit_s; char exit_w; char exit_e; } room; room map[MAP_WIDTH][MAP_HEIGHT]; void generate_map(); And this map.c: #include "map.h" void generate_map() { char room_x, room_y; ro...
Hi all, Wrote a very simple C function to illustrate what I would like to simplify: void main(int argc, char *argv[]){ char *me="Foo"; char *you="Bar"; char us[100]; memset(us,100,0x00); sprintf(us,"You: %s\n",you); sprintf(us+strlen(us),"Me: %s\n",me); sprintf(us+strlen(us),"We are %s and %s!\n",me,you); ...
This is my version of detab, from this K&R exercise: Modify detab to accept a list of tab stops as arguments. Use the default tab setting if there are no arguments. #include <stdio.h> #include <stdlib.h> #define TAB_STOP 8 /* replaces tabs from input with the proper amount of blank spots */ int Detab() { int c, x; int co...
Hi, I have a structure and a bidimensional array of those structs: typedef struct { char exit_n; char exit_s; char exit_w; char exit_e; } room; room map[MAP_WIDTH][MAP_HEIGHT]; I need an array of pointers those structs. The following code compiles, but I don't get the wanted result. Any help? This is getting really confused to me, a...
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #define TAB_STOP 8 /* replaces tabs from input with the proper amount of blank spots */ int Detab() { int c, x; int column; x = column = 0; while((c=getchar())!=EOF) { if(c == '\n') /* reseting counter if newline */ { putchar(...
In college I was asked if our program detects if the string enter from command line arguments is a integer which it did not(./Program 3.7). Now I am wondering how I can detect this. So input as for example a is invalid which atoi detects, but input like for example 3.6 should be invalid but atoi will convert this to an integer. #includ...
Hey all, First of all, I want to know if this is possible: let's say I have an unsigned long which contains some abritrary unsigned shorts, which may or may not be in the number. For example: unsigned short int id1 = 3456, id2 = 30998; unsigned long long bitfld = id1|id2; Can the other 2 fields be assumed as 0? An...
Hello gcc 4.4.1 I am writing a server program where many clients will connect to the client and the server will manage the clients request and manage the state of the client. Many clients under high load would be a deciding factor in using Asynchronous programming. However, I have never done Async in C. However, from what I understand...
I'm going through quiz answers from my professor and a question was: the correct implementation of a function like macro for absolute value is: #define abs(x) ((x)<0 ? (-x) : (x)) #define abs(x) ((x)<0 ? -(x) : (x)) Why is the second one correct vs the first one? And why do you have to use all the (). Like what are the rules invol...
I wrote a line drawing algorithm using the wu technique. It works but has issues. See below. What I'm wondering is if anyone has tackled the problem of drawing anti-aliased lines? Suprisingly, a google search results in no satisfactory algorithms. Lots of discusions, but not a single complete, robust algorithm, independent of any dep...
Hi, I'm a C# programmer of web applications. Weeks ago, I asked a question on stackoverflow about What should a software engineer (web) start by learning - Erlang, Haskell, Python, C++, F#. Thanks to all of those who suggested their thoughts and help to make a decision. I've found Python should be the one I should start looking forward...
i have a c program below: #define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); } when i run just the preprocessor it expands this as { int var12=100; printf("%d",var12); } which is the reason why the output is 100. can anybody tell me how/why the preprocessor expands var##12 to var12? ...
What is the formula for real world (latitude,longitude) conversion into (x,y) coordinates? ...
I have an application written in C for a Xilinx Microblaze core. However, the performance isn't quite what I want so I was considering rewriting some of the core functions in assembly. I'm having trouble figuring out how to get Xilinx Platform Studio to compile both into a single ELF file though. How can I do it? ...
Scenario is: nthreads = 8 for j=0 = nthreads pthread_created (thread_func) for 1=0 to 1000 { // Some work. for j=0 = nthreads sempost(mutex1) // thread_func() for j=0 = nthreads semwait(mutex2) // Some work. } thread_func() { w...
I have read the existing questions on external/internal linkage over here on SO. My question is different - what happens if I have multiple definitions of the same variable with external linkage in different translation units under C and C++? For example: /*file1.c*/ typedef struct foo { int a; int b; int c; } foo; foo xy...
Hi to all, I'm programming a very simple socket server following this sample code. The server is up and running and I can connect to it via telnet (using Putty, actually). Whenever a new connection is received, I spawn a new thread that is the following code: DWORD WINAPI receive_cmds(LPVOID lpParam) { char outbuffer[100]; ...
I am using a table layout panel with autoscroll = true I found several issues which don't seem to work properly. One of them is that when I have more rows then in view and the vertical scroll bar is added along with the horizontal scroll bar. Actually this horizontal scroll bar should not appear until unless it exceeds the width of th...
Possible Duplicate: What is a good book to study data structures in C? Please recommend a good beginner-intermediate book on data structures. Preferably a printed book, with code in C (or language-agnostic). ...