Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Dev Hardware ForumsSOFTWAREProgramming
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!

Download and Activate to enter!
Open source technologies have proven to be extremely advantageous to businesses.
This adaptive and highly efficient kind of software is central to the infrastructure of most companies. Since the world of open source technology is constantly changing,
IT professionals need a resource to give them up-to-the-minute information about these enterprise level and open source technologies. Dev Shed is that resource .
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today. .

Download to Enter | Contest Rules

Tutorials | Forums

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Hardware Forums Sponsor:
  Trader Rating: 0 · #1  
Old August 11th, 2009, 10:01 AM
I_have_no_idea I_have_no_idea is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 1 I_have_no_idea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 57 sec
Reputation Power: 0
C - Help please

I'm just starting to learn some programming and i'm using Dev-C++ to compile my programs. I can't work out why the following won't work, especially seeing as system("pause"); has worked in other programs:

/* Demonstrates using multiple return statements in a function. */

#include <stdio.h>

int x, y, z;

int larger_of(int a, int b);

int main()
{
puts("Enter two different integer values: ");
scanf("%d%d", &x, &y);

z = larger_of(x, y);

printf("\nThe larger value is %d.", z);
system("pause");
return 0;

}

int larger_of(int a, int b)
{
if(a>b)
return a;
else
return b;
}



I get an error message:

17 `system' undeclared (first use this function)

Can someone please tell me whats wrong - i'm probably being really stupid! I've tried using get(), getch(), getchar(), cin.get() all out of desperation but can't get anything to work!

Reply With Quote
  Trader Rating: 0 · #2  
Old August 11th, 2009, 06:25 PM
archnaid's Avatar
archnaid archnaid is offline
Moderator
Dev Hardware Specialist (4000 - 4499 posts)
 
Join Date: Feb 2004
Posts: 4,112 archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)archnaid User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2Folding Points: 737264 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 1 Month 1 Week 6 Days 17 h 51 m 19 sec
Reputation Power: 7080
There's a library you have to include to be able to use the 'system()' call. I can't remember what it is offhand, I've used it in C++ but it's been ages ago.

If you've used it in other programs, check your headers on those source files.

Reply With Quote
  Trader Rating: 0 · #3  
Old August 27th, 2009, 03:47 PM
mphill's Avatar
mphill mphill is offline
untitled
Click here for more information
 
Join Date: Oct 2005
Location: Zagreb
Posts: 3,936 mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)  Folding Points: 14729 Folding Title: Novice Folder
Time spent in forums: 3 Months 3 Weeks 4 Days 23 h 23 m 18 sec
Reputation Power: 9876
Send a message via ICQ to mphill
Facebook
You need to add

#include <stdlib.h>
__________________
Click Here ->    

Reply With Quote
  Trader Rating: 1 · #4  
Old August 28th, 2009, 04:12 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Dev Hardware Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2006
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,902 Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)  Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 2 Weeks 3 Days 20 h 11 m 15 sec
Reputation Power: 4058
Send a message via ICQ to Itsacon
btw, the system("pause"); is a pretty stupid crutch.

Just open a cmd terminal and run the program from there, and your output won't vanish.
__________________
This is my sig. Is it not nifty?
Itsacon's Sig v2. Click here =>    

Reply With Quote
  Trader Rating: 0 · #5  
Old August 28th, 2009, 02:45 PM
mphill's Avatar
mphill mphill is offline
untitled
Click here for more information
 
Join Date: Oct 2005
Location: Zagreb
Posts: 3,936 mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)mphill User rank is General 133rd Grade (Above 100000 Reputation Level)  Folding Points: 14729 Folding Title: Novice Folder
Time spent in forums: 3 Months 3 Weeks 4 Days 23 h 23 m 18 sec
Reputation Power: 9876
Send a message via ICQ to mphill
Facebook
Quote:
Originally Posted by Itsacon
btw, the system("pause"); is a pretty stupid crutch.

Just open a cmd terminal and run the program from there, and your output won't vanish.

You are expecting too much from windows user .
:P

EDIT:
I mean to expect from windows user to start it from cmd.

Reply With Quote
  Trader Rating: 1 · #6  
Old August 29th, 2009, 05:20 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Dev Hardware Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2006
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,902 Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)Itsacon User rank is General 46th Grade (Above 100000 Reputation Level)  Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2698830 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 2 Weeks 3 Days 20 h 11 m 15 sec
Reputation Power: 4058
Send a message via ICQ to Itsacon
By using C, he's shown he's willing to learn... :-)

Reply With Quote
Reply

Viewing: Dev Hardware ForumsSOFTWAREProgramming > C - Help please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
     
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
LOADING INFUSIONSOFTLOADING INFUSIONSOFT 1debug:overlay status: OFF
overlay not displayed overlay cookie defined: TI_CAMPAIGN_1012_D OVERLAY COOKIE set:
status off