| | |
func return 2 values
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2009
Posts: 36
Reputation:
Solved Threads: 0
like this ??
if yes, but we use the structer, and we should just use in the function the pointers without anything else ....
this is the code:
if yes, but we use the structer, and we should just use in the function the pointers without anything else ....
this is the code:
C Syntax (Toggle Plain Text)
#include <stdio.h> struct mytype { int ok; char ch; } mytype; struct mytype fundCalculation(int *a,int *b,int *c) { struct mytype tmp; if(*c==*a+*b) {tmp.ok=1;tmp.ch='+';} else if(*c==*a-*b) {tmp.ok=1;tmp.ch='-';} else if(*c==*a * *b) {tmp.ok=1;tmp.ch='*';} else if(*c==*a / *b) {tmp.ok=1;tmp.ch='/';} else {tmp.ok=0;tmp.ch=' ';} return tmp; } main() { int x=3; int y=4; int z=12; printf("%i %c ",fundCalculation(&x,&y,&z).ok,fundCalculation(&x,&y,&z).ch); getchar(); }
![]() |
Similar Threads
- How do I recognise strings and numbers (Python)
- How to create a .lib from a .def? (C++)
- Any help is appreciated (C++)
- so I find myself here again (C++)
- Return more than one value from a single function (C++)
Other Threads in the C Forum
- Previous Thread: Thread Scheduling - Please Help
- Next Thread: An implementation idea requied in Compiler Interface
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches initialization intmain() iso km license linked linkedlist linux linuxsegmentationfault list logical_drives loopinsideloop. lowest match matrix microsoft motherboard mqqueue multi mysql oddnumber odf open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings suggestions test testautomation unix urboc user variable whythiscodecausesegmentationfault win32api windows.h






