Mujhy aik aysi program banao jis mai hum aik line dy jis mai humain ye us line mai mojood words gin k bataye.masllan "hum pakistani hai"
Is mai 3words hai.anyone
Mujhy aik aysi program banao jis mai hum aik line dy jis mai humain ye us line mai mojood words gin k bataye.masllan "hum pakistani hai"
Is mai 3words hai.anyone
اس کو چیک کریں
----------
#include <stdio.h>
int main (void) {
char *line = NULL; /* pointer to use with getline () */
char *p = NULL; /* pointer to parse getline return */
ssize_t read = 0;
size_t n = 0;
int spaces = 0; /* counter for spaces and newlines */
int total = 0; /* counter for total words read */
printf ("\nEnter a line of text (or ctrl+d to quit)\n\n");
while (printf (" input: ") && (read = getline (&line, &n, stdin)) != -1) {
spaces = 0;
p = line;
if (read > 1) { /* read = 1 covers '\n' case (blank line with [enter]) */
while (*p) { /* for each character in line */
if (*p == '\t' || *p == ' ') { /* if space, */
while (*p == '\t' || *p == ' ') /* read all spaces */
p++;
spaces += 1; /* consider sequence of spaces 1 */
} else
p++; /* if not space, increment pointer */
}
}
total += spaces + 1; /* words in line = spaces + 1 */
printf (" chars read: %2zd, spaces: %2d total: %3d line: %s\n",
read, spaces, total, (read > 1) ? line : "[enter]\n");
}
printf ("\n\n Total words read: %d\n\n", total);
return 0;
}
یہ شاٹ طریقہ ہے
#include <stdio.h>
#include <conio.h>
void main(){
char s[50],ch;
int i,c=0;
clrscr();
printf("Enter any string : ");
for(i=0;ch!='\n';i++){
ch=getchar();
s[i]=ch;
}
s[i]='\0';
for(i=0;s[i]!='\0';i++){
if(s[i]==' '){
c++;
while(s[i]==' ')
i++;
}
}
printf("\n\nTotal words are %d",c+1);
getch();
}
لگتا ہے کہ ممبر کا مسلہ حل ہو گیا ہے اسی لئے ریپلائی نہیں کیا ابھی تک اس نے
Bookmarks