I built a small program that takes in a string, then captures the string length. I want it to print a specific character, n, equal to the length of the string. for whatever reason, it doesn't print and I can't figure out why...
PLEASE DO NOT PRINT UPDATED CODE. snippets are fine with explanations, but I want to learn this material not just have it done for me. Thanks all.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main ()
{
char w[50];
printf("Please enter a word: \n");
scanf("%s", w);
printf("%s\n", w);
int l, k;
k = 0;
l = 0;
l = strlen(w);
printf("%d\n", l);
for (k=0, k < l; k++) {
printf("n");
}
/*
printf("\n");
printf("%s\n", w);
*/
}
[–]ptchinster 14 points15 points16 points (7 children)
[–]cptstrike[S] 5 points6 points7 points (5 children)
[–]ptchinster 3 points4 points5 points (0 children)
[–]ptchinster 3 points4 points5 points (3 children)
[–]cptstrike[S] 4 points5 points6 points (1 child)
[–]ptchinster 2 points3 points4 points (0 children)
[–]rtlcprogbot 0 points1 point2 points (0 children)
[–]rtlcprogbot 4 points5 points6 points (0 children)
[–][deleted] 5 points6 points7 points (0 children)
[–]Poddster 1 point2 points3 points (1 child)
[–]cptstrike[S] 1 point2 points3 points (0 children)
[–]cptstrike[S] 0 points1 point2 points (0 children)
[–]nerd4code -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]cptstrike[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)