Solved

printf dont work

Posted on 2010-11-30
5
378 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SqlDataBase 7 53
Service Controller 1 28
VS2013 publish C# application Created folder -- where is it??? 10 28
C# Linq - Join two objects into one 3 14
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

829 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