C :: Float Showing Nothing In Printf

Oct 6, 2014

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

Code:
#‎include <stdio.h>
int main() {
char arr[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
printf("Size of char=%c
", ((char *) (&arr[0]))[1]);

[Code] ....

View 14 Replies


ADVERTISEMENT

C++ :: Turning A Limited Float Into Another Float?

Nov 20, 2013

I can do the folowing:

float var1 ;
var1 = 9.12345 ;
printf("%.2f",var1) ;

the output will be 9.12. What if I wanted to save that as another separate float with displaying it on screen?

View 1 Replies View Related

C/C++ :: Cannot Convert Float To Float Assignment

Jun 8, 2014

#include <iostream>
#include <string.h>
#include <sstream>

[Code]....

View 1 Replies View Related

C :: How To Printf Floats

Jan 30, 2013

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.

Code:
#include <stdio.h>
#define TICKER "LRCX"
#define PURCHASE_DATE "01/02/13"
#define SELL_DATE "01/30/13"
#define INVESTMENT_AMOUNT "10,000.00"

[Code] .....

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:

Stock: MCD Buy Date: 01/02/13 Sell Date: 01/29/13 Buy Share Price: $89.40 Sell Share Price: $91.50 Shares Purchased: 111.86

Amount of Investment: $10,000.00 Value of Shares Sold: $10,234.90 Amount of Gain/Loss: $234.90 Percent Gain/Loss: 2.35%

However, this is how mine turns out:

Code::Blocks
Enter share purchase price for LRCX=>23
Enter the selling price for LRCX=>23

Stock: LRCX
Buy Date: 01/02/13
Sell Date: 01/30/13
Buy Share Price: -1.#R
Sell Share Price: -1.#R
Shares Purchased: -1.#R

Amount of Investment: 10,000.00
Value of Shares Sold:-1.#R
Amount of Gain/Loss:-1.#R
Percent Gain/Loss:-1.#R%

Process returned 0 (0x0) execution time : 2.864 s
Press any key to continue.

View 3 Replies View Related

C :: How To Printf A Struct

Apr 22, 2014

Code:

#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?

View 4 Replies View Related

C++ :: From Printf To String

May 6, 2013

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?

printf ("Some different radixes: %d %x %o %#x %#o
", 100, 100, 100, 100, 100);

View 3 Replies View Related

C/C++ :: How To Skip The Value In Printf

Sep 5, 2014

#include<stdio.h>
void main()
{
int i=6;
printf("%d %*d
",i,i+9);
}

what is the out put?

View 2 Replies View Related

C++ :: Printf In Loop

Jul 17, 2013

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?

View 2 Replies View Related

C++ :: SDL Font Not Showing

Jan 19, 2013

SLD_ttf lib and I have been following the Lazy Foo' tuts on it but the text is not appearing. I have found out that it is not loading the font as I have added in the code saying if it has failed.

Code:

font = TTF_OpenFont( "lazy.ttf", 28 );
if( font == NULL )
{
return false;
}

i have saved this font in the project (project name/project name/lazy.ttf).

View 19 Replies View Related

C++ :: Image Not Showing On Top

Jul 1, 2013

I am trying to display images on top of my Background image gui, so like buttons an stuff but the problem is that there not showing ontop. I can only get one of them to show

// includes
#include <windows.h>
#include <stdio.h>
#include "res.h"

// defines
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002

[Code] ....

View 1 Replies View Related

C :: Printf In A While Loop Is Printing Twice Instead Of Once

Sep 21, 2013

I have a minor issue in my program:

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.

View 2 Replies View Related

C :: Printf Int That Was Defined In Another Function?

Feb 26, 2013

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.

Assignment Grades:
18 12 17 15 20 13
20 18

View 9 Replies View Related

C :: How To Center Text Using Printf

Jul 23, 2014

The overall width of the line is 20 characters. How can I center a string using print so that

title becomes
space-title-space

i have something like this so far Code: fprintf(myfile, "%20s ",mystring);

View 2 Replies View Related

C++ :: Input Using Printf / Scanf

Oct 28, 2014

How to store the value in this case.. The topic is called "limited summation".. The following is the guideline for this problem:

Write a program in a folder called "sum" with a source file of main.cpp that does the following:

•prompt a user to enter a maximum number of entries, make the prompt "max # entries"

•prompt a user to enter a threshold sum, make the prompt "threshold"

•using error checking logic, let a user enter base-10 signed numbers until at least one of the following conditions is true:

or the maximum number of entries is reached
or the sum of entered numbers has reached (>=) the threshold

•print the sum of all the entries, just the number and a linefeed at the end of the line

Error checking means entries that are not numbers are detected and ignored. You are to use printf and scanf in this assignment (no cin or cout).

View 3 Replies View Related

C/C++ :: Why Does Printf Not Print After A While Or For Loop

Jul 1, 2012

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.

View 7 Replies View Related

C++ :: Output Is Showing Address Instead Of Value

Dec 7, 2013

I've run across this issue before, but for the like of me, I can't figure out what keeps causing it. The problem compiles and runs as expected; however in the salaried object (Employee #1 in main.cpp) the console displays the number of vacation days as -858993460 instead of the value entered.

The parent Employee class is abstract with calculatePay() and displayEmployee() being pure virtualls and with a Benefits, Salaried, and Hourly class derived from it.

The Salaried displayEmployee() and the portion of the Main.cpp that contains the salaried object follows. What causing this?

Salaried displayEmployee()
Code:
void Salaried::displayEmployee()
{
cout << endl;
cout << "Employee Information" << endl;
cout << "----------------------------------" << endl;
cout << "Employee Name: " << setw(7) << FirstName << " " << LastName << endl;
cout << "Gender: " << setw(12) << Gender << endl;

[Code] .....

View 2 Replies View Related

C :: Calculating And Showing RPM On Display

Feb 19, 2014

As part of a project i want to display the speed of a small wheel on a 7 segment display. I am using a hall effect sensor to pick up the pulses of the rotation. I am not sure how to write a programe on C to calculate the RPM from this....

View 4 Replies View Related

C++ :: Calculations Are Done Correctly But Showing Zero

Nov 26, 2013

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

View 1 Replies View Related

C/C++ :: Showing The First Digit Of Zip Code?

Nov 21, 2014

My question is why my on my code there is 10 zip code and i want to show the first digit, the problem is the first digit does not match the zip code for example the zip code is 45805 it should be '5' however, my code shows other number!

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

[Code].....

View 4 Replies View Related

C++ :: CPP File Not Showing Code

Nov 19, 2013

i have been making code of a chessgame and now sddenly computer freezed and now there's not code in .cpp file! Although my .cpp file shows size of 16kb but when i open it . there's nothing except bank file

View 1 Replies View Related

C++ :: Tic Tac Toe - Board Is Not Showing Numbers

Feb 7, 2014

I'm programming tic tac toe but the board is not showing numbers, and it is simply stating the winner without any input: (the win conditions are not complete, but it shouldn't matter).

#include <iostream>
#include<string>
using namespace std;
//Write a two-player tic-tac-toe game; use enums when possible to represent the values of the board

char ticBoard[3][3];
char board[10];
void showBoard();
bool moveIsValid(int m);
int whoWon(); // 0 tied, 1 p1, 2 p.2

[Code] ....

View 6 Replies View Related

C# :: Variable Showing As Not Instanced

Oct 19, 2014

I'm receiving an error that an array has not been initialized but I'm not quite sure why. Also, I realize a list may be better in this scenario but I would still like to know what I'm doing wrong.

Warning in the IDE

Warning3Field 'Routines.SvrMain.Servers' is never assigned to, and will always have its default value nullD:Google DriveCodingC# ProjectsNONameWindowsFormsApplication1WindowsFormsApplication1Routines.cs26638WindowsFormsApplication1

Error that pops on line
Servers[Index].Address = Parser.ReturnAddress(); //returns an IPAddress

Object reference not set to an instance error

ServerDetails Class
public class ServerDetails {
public IPAddress Address; { get; set; }
public int Port { get; set; }
}

[Code] ....

View 12 Replies View Related

C/C++ :: Why Invalid Letter Not Showing

Feb 29, 2012

I wanna know why the program doesnt show "Invalid Letter Entered" when i enter any letter other than A S D or M

//Processing the data
    if (letter== 'A'||'S'||'M'||'D')// checking Add, subtract, multiply or divide {
        if (letter== 'A')//Adding the integers
            cout<<"Adding two integers = "<<first + second<<endl;
        else if (letter== 'S')//Subtracting the integers  {

[code]......

View 1 Replies View Related

C :: Printf Doesn't Print On Screen

May 23, 2013

This code runs. However, when I run it, the text from printf doesn't appear until after I type in the two numbers.

I use Wascana, will it run correctly on other compilers?

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
fflush(stdout);

[Code].....

And this is how it turns out on the screen:

Code:

6
3

What size is the die:

how many dice to roll:

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

The total is: 14

View 4 Replies View Related

C :: Global Variable - Only Printf Works

Apr 20, 2013

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

printf("%u" , VOLUME_1_SECTOR);
if(VOLUME_1_SECTOR==16384)
printf("Correct");
else
printf("Incorrect");

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.

View 2 Replies View Related

C :: How To Copy Result Of Printf Into Array

Oct 12, 2013

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]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved