I am having trouble with the printf in this function:
Code:
void print_orig_array(char string_array[MAX_PEOPLE][NAME_SIZE], int ages[MAX_PEOPLE], int length) {
int counter;
printf("Original list");
printf("
[URL] ....
Here is the output:
Am I missing something with the format specifier? How do I fix the 84 that gets pushed out?
Code: char Answer; printf(" To search for a specifc word, type (Y), to use a dictionary file, type (N):
[Code] .....
When I run the program, it gives:
To search for a specific word, type (Y), to use a dictionary file, type (N):
Sorry, the given input is invalid, please try again:
I can then input the number. Typing n,N,y or Y goes to the next part of the program without any problems, but if I type something else, I get:
Sorry, the given input is invalid, please try again:
Sorry, the given input is invalid, please try again:
I've fiddled about with the code for a while now, but nothing I do seems to work. What is causing it to be printed twice, or why the first getchar() is ignored.
I would like the following code to print: "Why doesn't this print?" and "I would like to print the sum of nc: 5". What am I doing wrong.
#include <stdio.h> //Use to test ideas and formats// main() { int c, nc; nc = 0;
[code]....
My result as compiled by gcc -o testing testing.c
This prints.
test t1,e2,s3,t4, 5,
I have not figured out how to sum and print as the above code indicates, which complicates my ability to do many of the exercises in "The C Programming Language". I am using a MacBook gcc compiler and X code as well. I cannot get the last two printf functions to work. I did the temperature example with "while (fahr <= upper)" and the printf printed.
I am having a hard time with some of my homework, specifically regarding how to printf floats. I can't seem to print the number i want out using float, it just becomes a jumbled mess.
Thats the code I currently have, I've probably tried everything to get the number to come out, but I just cant seem to figure it out. It should look like this, but with different numbers and stock:
#include <stdio.h> struct database { int id_number; int age; float salary;
[Code] ....
When I compile, I get an error: test.c|18|error: incompatible type for argument 1 of 'printf'| note: expected 'const char *' but argument is of type 'float'|
I thought employee.salary is a float but the compiler expected 'const char'. How do I make this work?
I have the following line of the code. Now I want to save the content to a string. Is there a quick way for me to do the conversion using the same arguments/codes of printf?
I'm making my way through most of this assignment that I have, but now it seems like I've run into a bit of a roadblock. The issue that I'm having is not being able to printf a series of ints that I thought I had previously defined in another function. I don't want to clog up this post with the entire code, so I'll just post one function that defined an int to give an example. I will upload the whole thing upon request however.
Code:
#include <stdio.h> #include <stdlib.h> //Prototypes int AGrade1(int* grade1); int AGrade2(int* grade2); int AGrade3(int* grade3);
[Code] .....
I've tried many many things, but I just cant figure it out. This is what it's supposed to look like.
I just checking but confused with float. in that code same size int, and same type double are working but float showing nothing in printf..why?? i'm using GCC compiler int 32bit win7 os
Numbers are 3d6 Rolling die no.1... RolledDie: 4 DieTotal: 4 Rolling die no.2... RolledDie: 5 DieTotal: 9 Rolling die no.3... RolledDie: 5 DieTotal: 14
Okay so I am programming an 8051 variant to interact with an SD card. In a separate initialization routine in SD_CARD.c I pull out the vital information of the card into global variables. I then call Menu() which is in another source file but includes a header file with all of the variables declared as extern. Now here is the weird, part this is from my Menu.c
Now the output of the first printf is 16384 but the conditional evaluates to false. If I put this code in SD_CARD.c (Where VOLUME_1_SECTOR is defined) the conditional evaluates to true. I am confused why the printf works correctly in Menu.c but not the conditional.
I am trying to compare 2 strings of characters The users input containing 5 chars is compared to a table If the input is already be existent in the table the index of those chars in the table is printed Quest: how to copy the result of a printf() into an array ? The last printf() gives a sequence of numbers and I am trying to save that sequence to another array for further operation ! I have not been able to do that so far even with tmp[]=i ;
Code: #include <stdio.h> #include <string.h> #define N 30 #define n 100 int main (void) [code]....
I'm trying to create a program that will show what the 12th digit of a UPC code would be. However, once the user enters the first 11 digits the program doesn't execute the last call of printf. The program compiles with no issues.
Code:
#include<stdio.h> int main() { int o1, e2, o3, e4, o5, e6, o7, e8, o9, e10, o11, oddsum, evensum, twelve; printf
I cannot get the following to compile. The problem is the printf on the last line. I understand that printf requires a char (or pointer to char). I understand that I can convert between datatypes by putting the target data type in parenthises in front of the variable. But how do I cast the integer into a character and then get it's pointer to pass into printf?
Following is my code. I compile with gcc temp.c -o temp.
Note that I have tried many attempts at that last line and this is just the one that I really, really think should work (or is at least the closest to the correct answer).
This code shown below, using printf("%s", &(char)nextChar); returns
temp.c:26: error: lvalue required as unary '&' operand
If I try to use printf("%s", *(char)nextChar); I get the error
temp.c:26: error: invalid type argument of 'unary *' (have 'int')
This line printf("%s", (char)nextChar); returns the obvious
format '%s' expects type 'char *', but argument 2 has type 'int'
Code:
#include <stdio.h> int main() { printf("hello, world "); #if defined(SUNDIALS_EXTENDED_PRECISION)
I have gotten it to record the date and I can printf it either on the same function, or in the main(). However, one of the requirements I must adhere to is to printf the statement in a brand new function, but when I do that, it just doesn't work. Heres what I mean:
Code:
#include <stdio.h> #define TICKER "LRCX" #define INVESTMENT_AMOUNT "10,000.00" //Prototypes int getdate(int* month1,int* day1,int* year1,int* month2,int* day2,int* year2); float getprice(float* BPrice, float* SPrice); void printdate(int month1, int day1, int year1); }
As you can see I am trying to re-crate the output from the first loop in my second loop, however it is with little success. The second loop's first run re-crates the last output of the first loop and if I use FileStructPointer++ or -- the output goes broke.
See attached for how it looks in the console window.
I am using print/sprintf with a "%i" format string. Works fine if the input is indeed a 32bit integer. But how can i put in 8/16 bit (ie short & byte) 'integers'? If i just throw them in, they are always taken as unsigned, as the topmost bit/s is/are casted to zero... [URL] ....
This is supposed to output t=m and then m is plugged into a function say for -3, plugging it into function f gives 23, well i want 22 blank spaces and then a asterik and go to next line. that is why i put -1 after %'f(m)-1's i
The asterisk appear right next to the t value here but they are way to the right of it when i made this post.
I'm trying to get this programme to work but I can't get it to output the string data at the end of the line.I have copied and pasted the line in question below but it may be a prob with the prog further down.
It reads character input ok but doesn't put one string into another or recognize when a string is quoted in a printf.
Code: printf("%s what is your second name? ", surname, name2, name); #include <stdio.h> int main () { char name[20];