Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
mod 4
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include <stdio.h> #include <stdlib.h> int compara(const void *dato, const void *clave) { int *ptrDato = (int *) dato; int *ptrClave = (int *) clave; return (*ptrDato) - (*ptrClave); } int main(void) { int vector[6] = {10,20,30,40,50,60}; int clave = 20; int *ptr = (int *) bsearch(&clave, vector, 6, sizeof(int), compara); int posicion; if (ptr == NULL) printf("%d NO ESTA EN VECTOR ",clave); else { printf("%p\n",ptr); printf("%p\n",vector); posicion = ptr - vector; printf("%d ESTA EN VECTOR en posicion %d",clave,posicion); } return 0; }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.12 sec, absolute running time: 0.16 sec, cpu time: 0.01 sec, memory peak: 5 Mb, absolute service time: 0,39 sec
edit mode
|
history
|
discussion
0x7ffd25271c14 0x7ffd25271c10 20 ESTA EN VECTOR en posicion 1