Search Results

Search found 916 results on 37 pages for 'stdio'.

Page 5/37 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • newbie in c and issue with integers [migrated]

    - by user2527918
    // // main.c // cmd4 // // Created by Kevin Rudd on 27/06/13. // Copyright (c) 2013 Charlie Brown. All rights reserved. // #include <stdio.h> int main(int argc, const char * argv[]) { int x =10, y =20, b = 500; int z = x*y; int f = z/b; // insert code here... printf("x is:%d, y is:%d, b is %d\n",x,y,b); printf("x times y is: %d\n",z); printf("z divided by b is: %d\n",f); return 0; } on print out f = 0. Why?

    Read the article

  • reading k&r(c book) and confusing 1st chapter code [closed]

    - by DarkEnergy
    #include <stdio.h> /* copy input to output; 2nd version*/ main() { int c; while ((c = getchar()) != EOF) putchar(c); } this is very confusing... since you never escape the while loop. I've learned that EOF is -1. i type -1 but it just reprints it. It's a never ending loop. Over time did the library get changed and differs from what the book intended it to be? when i say library i mean the putchar()/getchar() that's in the library... sorry.

    Read the article

  • How to write basic matrix using row and column differently

    - by kounabg
    #include<stdio.h> #include<conio.h> int main() { int a[3][3],i,j; for(i=0;i<3;i++) {printf("enter the value of row A: ",a[i]); scanf("%d",& a[i]);} for(i=0;i<3;i++) {printf("enter the value of row B: ",a[i]); scanf("%d",& a[i]);} for(i=0;i<3;i++) {printf("enter the value of row C: ",a[i]); scanf("%d",& a[i]);} } ***I did this. I want to convert it into matrix and how can I do it?

    Read the article

  • Getting Windows 7 SUA's bash shell working with emacs (EmacsW32)?

    - by landstatic
    Having recently purchased Windows 7 Ultimate in order to gain access to the SUA subsystem, I have been struggling to get SUA's bash utility (/usr/local/bin/bash) working with EmacsW32. M-x shell normally invokes a shell process and pipes stdio through an Emacs buffer and this works well with Cygwin e.g. Cygwin is very slow compared to SUA however, so I am very keen to get this facility working with the EmacsW32 + SUA combo. Any tips, experience, solutions would be appreciated.

    Read the article

  • Defining a Class in Objective C, XCode

    - by Brett
    Hello; I am new to Objective C, and am trying to write a class that defines a complex number. The code seems fine but when I print to the console, my values for instance variables are 0. Here is the code: // // ComplexNumber.h // Mandelbrot Set // // Created by Brett on 10-06-02. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import <stdio.h> @interface ComplexNumber : NSObject { double real; double imaginary; } // Getters -(double) real; -(double) imaginary; // Setters -(void)setReal: (double) a andImaginary: (double) b; //Function -(ComplexNumber *)squared; @end // // ComplexNumber.m // Mandelbrot Set // // Created by Brett on 10-06-02. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "ComplexNumber.h" #import <math.h> #import <stdio.h> @implementation ComplexNumber -(double)real{ return self->real; } -(double)imaginary{ return self->imaginary; } -(void)setReal: (double) a andImaginary: (double) b{ self->real=a; self->imaginary=b; } -(ComplexNumber *)squared{ double a = pow(real,2); double b = pow(imaginary, 2); double c = 2*real*imaginary; ComplexNumber *d; [d setReal:(a-b) andImaginary: c]; return d; } @end In the App Delegate for debugging purposes I added: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ComplexNumber *testNumber = [[ComplexNumber alloc] init]; [testNumber setReal:55.0 andImaginary:30.0]; NSLog(@"%d", testNumber.real); // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } But the console returns 0 everytime. Help?

    Read the article

  • Compiler error: memset was not declared in this scope

    - by michael
    Hi, I am trying to compile my c program in ubuntu 9.10 (gcc 4.4.1). I am getting this error: Rect.cpp:344: error: ‘memset’ was not declared in this scope But the problem is I have already included in my cpp file: #include <stdio.h> #include <stdlib.h> And the same program compiles fine under ubuntu 8.04 gcc 4.2.4). Please tell me what am i missing. Thank you.

    Read the article

  • Bidirectional FIFO

    - by nunos
    I would like to implement a bidirectional fifo. The code below is functioning but it is not using bidirectional fifo. I have searched all over the internet, but haven't found any good example... How can I do that? Thanks, WRITER.c: #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <fcntl.h> #define MAXLINE 4096 #define READ 0 #define WRITE 1 int main (int argc, char** argv) { int a, b, fd; do { fd=open("/tmp/myfifo",O_WRONLY); if (fd==-1) sleep(1); } while (fd==-1); while (1) { scanf("%d", &a); scanf("%d", &b); write(fd,&a,sizeof(int)); write(fd,&b,sizeof(int)); if (a == 0 && b == 0) { break; } } close(fd); return 0; } READER.c: #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <fcntl.h> #include <sys/stat.h> #define MAXLINE 4096 #define READ 0 #define WRITE 1 int main(void) { int n1, n2; int fd; mkfifo("/tmp/myfifo",0660); fd=open("/tmp/myfifo",O_RDONLY); while(read(fd, &n1, sizeof(int) )) { read(fd, &n2, sizeof(int)); if (n1 == 0 && n2 == 0) { break; } printf("soma: %d\n",n1+n2); printf("diferenca: %d\n", n1-n2); printf("divisao: %f\n", n1/(double)n2); printf("multiplicacao: %d\n", n1*n2); } close(fd); return 0; }

    Read the article

  • Most complicated C code to read

    - by cprogrammer
    ITT: Post a program that doesn't do anything, but breaks all syntax highlighting. ??=include<stdio.h> // lol????/ why does this compile???????/ haha :> int main()<%int lol<:0x1UL??);printf("%.""0s",(0[lol]??'=*lol,&lol<:(unsigned)"hi"??)));??>

    Read the article

  • Scanf fails with bus error

    - by Mikulas Dite
    I'm playing with C and I've run into this error: #include <stdio.h> int main () { char* foo; scanf("%s", foo); printf("entered %s", foo); return 0; } scanf takes pointer, foo is pointer, yet I get bus error. How can I make it work?

    Read the article

  • why do i see THROW in a C library

    - by Bhagya
    When I do: less /usr/include/stdio.h (which is only a C library - nothing to do with C++) I see __THROW after quite a few function declarations. Also, comments above a few functions say that 'This function is a possible cancellation point and therefore not marked with __THROW' What is all this for? THROW is meant to be for exception handling.. but as far as I know, C doesn't provide any support for it... Plz explain.

    Read the article

  • Go programming: How to get from cgo to exe

    - by Kawili-wili
    From a basic test program. . . package main /* #include <stdio.h> static void test() { printf("hello world"); } */ import "C" func main() { C.test(); } I do "cgo hello_cgo.go" and get: _cgo_.o _cgo_defun.c _cgo_gotypes.go hello_cgo.cgo1.go hello_cgo.cgo2.c How do I go about compiling from here to an exe?

    Read the article

  • Error in ternary expression

    - by Bipul
    Consider the following code which shows compile time error : #include <stdio.h> int main(int argc, char** argv) { int x=5,y=0,z=2; int a=z?x,y?x:(y); // but z?x,y?x:y:z is not showing any error printf("%d",a); return 0; } Please help me explain the reason why z?x,y?x:y:z is not showing any error?

    Read the article

  • Why no switch on pointers?

    - by meeselet
    For instance: #include <stdio.h> void why_cant_we_switch_him(void *ptr) { switch (ptr) { case NULL: printf("NULL!\n"); break; default: printf("%p!\n", ptr); break; } } int main(void) { void *foo = "toast"; why_cant_we_switch_him(foo); return 0; } gcc test.c -o test test.c: In function 'why_cant_we_switch_him': test.c:5: error: switch quantity not an integer test.c:6: error: pointers are not permitted as case values Just curious. Is this a technical limitation? EDIT People seem to think there is only one constant pointer expression. Is that is really true, though? For instance, here is a common paradigm in Objective-C (it is really only C aside from NSString, id and nil, which are merely a pointers, so it is still relevant — I just wanted to point out that there is, in fact, a common use for it, despite this being only a technical question): #include <stdio.h> #include <Foundation/Foundation.h> static NSString * const kMyConstantObject = @"Foo"; void why_cant_we_switch_him(id ptr) { switch (ptr) { case kMyConstantObject: // (Note that we are comparing pointers, not string values.) printf("We found him!\n"); break; case nil: printf("He appears to be nil (or NULL, whichever you prefer).\n"); break; default: printf("%p!\n", ptr); break; } } int main(void) { NSString *foo = @"toast"; why_cant_we_switch_him(foo); foo = kMyConstantObject; why_cant_we_switch_him(foo); return 0; } gcc test.c -o test -framework Foundation test.c: In function 'why_cant_we_switch_him': test.c:5: error: switch quantity not an integer test.c:6: error: pointers are not permitted as case values It appears that the reason is that switch only allows integral values (as the compiler warning said). So I suppose a better question would be to ask why this is the case? (though it is probably too late now.)

    Read the article

  • C : crypt function

    - by kiruthika
    Hi all, I have used the crypt function in c to encrypt the given string. I have written the following code, #include<stdio.h> #include<unistd.h> int main() { printf("%s\n",crypt("passwd",1000)); } But the above code threw an error ,"undefined reference to `crypt'". What is the problem in the above code. Thanks in advance.

    Read the article

  • C array assignment and indexing with similar variable.

    - by Todd R.
    Hello! I apologize if this has been posted before. Compiling under two separate compilers, BCC 5.5 and LCC, yields 0 and 1. #include <stdio.h> int main(void) { int i = 0, array[2] = {0, 0}; array[i] = ++i; printf("%d\n", array[1]); } Am I to assume not all compilers evaluate expressions within an array from right to left?

    Read the article

  • How to pronounce "std" (C & C++)? [closed]

    - by Matt Blaine
    How do you pronounce "std"? As in: __stdcall stdlib.h stdio.h stdin stdout stderr the namespace std Thank you. Please don't take this as being rude, but if you'd like to close this question, there are many others like it that were allowed to survive. So, if you decide to close any of them, would you kindly close all of them? Thanks.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >