Sollicitatievraag bij Servion Global Solutions

string length for commend line argument.

Antwoorden op sollicitatievragen

Anoniem

12 okt 2017

#include #include void main(int argc,char *argv[]) { int len; char *ptr; clrscr(); if ( argc != 2) { printf("\n Invalid arguments "); exit(0); } else { ptr=argv[1]; len=0; while ( *(ptr+len) != '\0') { len++; } printf("\n Length is %d",len); } }

4

Anoniem

27 sep 2020

public class strLength { public static void main(String args[]) { String s1="Test"; System.out.println("string length is: "+s1.length()); }}