Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Compiling
Compiling [message #1776637] Sun, 19 November 2017 18:49 Go to next message
Renseiga Chikaara is currently offline Renseiga ChikaaraFriend
Messages: 1
Registered: November 2017
Junior Member
Hello I made a simple code in c this is the codex:
#include <stdio.h>
#include <stdlib.h>

int main (){
int c[ 4 ],B[ 2 ];
int i,j,count=0;

for ( i = 0;i < 4; i++ ){
printf("enter number value\n");
scanf ("%d", &c[i]); //array of 4 values
printf("The number is %d\n",c[i]);
}
for ( i = 0;i < 2; i++ ){
B[i]=0; //making B values 0
}
for (i = 0;i < 2; i++ ){
for ( j = 0;j < 4; j++ ){
if((1+i)==c[j]){
B[i]=B[i]+1; //counts the frequency of a value and saves it in b (works for 1 and 2 as inputs)
}
}
printf("B is %d\n",B[i]);
}
printf("ENTER count number:\n ");
scanf ("%d", &count);
for ( i = 0;i < 2; i++ ){
if(count==B[i]){
printf(" %d",i); //user enters a count and prints all ints with the same frequency as count
}
}
return 0;
}

I used it with bigger arrays but it failed so I try to dbg it with less values and found out that the order of the commands aren't right, for instance the first printf is printed after all scanf from c array. I used BuildAll<Run and it always stops at the point where scanf of count is> Need help to fix it please.Thanks beforehand
Re: Compiling [message #1776675 is a reply to message #1776637] Mon, 20 November 2017 08:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Questions related using the C/C++ support are best asked on the CDT forum but this appears to purely a "how to C work" and that's probably best asked on a forum such as StackOverflow.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Eclipse does not finish to updatepacks
Next Topic:MAVEN with Eclipse Kepler and Galileo
Goto Forum:
  


Current Time: Thu Apr 18 18:16:56 GMT 2024

Powered by FUDForum. Page generated in 0.03465 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top