Solved

printf dont work

Posted on 2010-11-30
5
379 Views
Last Modified: 2012-05-10
hallo;

i use printf but its not working ?

why???
#include <stdio.h>
#include <conio.h>
int main (void)
{
    short tabel[]={16,23,-7,10,85,-18,16,8};
    short i=0;
    short totaal=0;
    short kleinste=tabel[0];
    short temp=0;
    short size= sizeof(tabel)/sizeof(short);

     i=0;
     while (i < size)
     {
           temp=tabel[i];
           if (temp < kleinste)
           kleinste=temp;
     }
     printf("\n\n de kleinste getal in de tabel is %hd",kleinste);
     
    
    getchar();
    
}

Open in new window

0
Comment
Question by:kensy11
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 34240759
What do you mean by "it's not working" ?

Does adding a \n at the end help ?

        printf("\n\n de kleinste getal in de tabel is %hd\n",kleinste);
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 34240780
Btw, main returns an int, so you also actually have to return an int value at the end of main (generally 0 to indicate success).
0
 

Author Comment

by:kensy11
ID: 34240793
when i run it or compile it i dont get any text its just a black screen
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 34240814
I just noticed that you're not incrementing i inside the loop, so the loop basically loops forever. You'll need to add a ++i somewhere near the end of the loop body.
0
 

Author Comment

by:kensy11
ID: 34240827
oooh thank you i forgot to do it
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question